Inno Setup - 等待 Postgres 数据库启动
Inno Setup - Wait for Postgres database to start
在下面的示例中,我想延迟 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
标志不出所料地没有起到作用并且延迟执行足够长的时间(如果有的话)。
那么有没有人有更可靠的方法来确保 createuser
在 Postgres (pg_ctl start
) 服务器命令 运行、空闲并准备好接受命令之前不执行?
使用 ewWaitUntilTerminated
标志与 -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.
在下面的示例中,我想延迟 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
标志不出所料地没有起到作用并且延迟执行足够长的时间(如果有的话)。
那么有没有人有更可靠的方法来确保 createuser
在 Postgres (pg_ctl start
) 服务器命令 运行、空闲并准备好接受命令之前不执行?
使用 ewWaitUntilTerminated
标志与 -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.