在下面的示例中,我想延迟执行 createuser
命令,直到 Postgres 服务器启动并运行。
if Exec('pg_ctl', 'start -D C:\ProgramData\PostgresQL\data', '', SW_SHOW, ewWaitUntilIdle, ResultCode) then
begin
Sleep(10000);
// Create our database user
if Exec('createuser', '-w -d -R -S testdb', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
不幸的是,使用任意Sleep()
是我设法实现此目的的唯一方法。不出所料,exWaitUntilIdle
标志并不能解决问题,并且会延迟执行足够长的时间(如果有的话)。
有没有人有更可靠的方法来确保在 Postgres (pg_ctl start
) 服务器命令运行、空闲并准备好接受命令之前不会执行 createuser
?
最佳答案
使用 ewWaitUntilTermulated
标志和 -w
switch :
Wait for the startup or shutdown to complete. Waiting is the default option for shutdowns, but not startups. ...
pg_ctl
returns an exit code based on the success of the startup or shutdown.
关于postgresql - Inno Setup - 等待 Postgres 数据库启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36844147/