'Inno Setup - Wait for Postgres database to start
In the example below I want to delay the execution of the createuser command until the Postgres server is up and running.
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)
Unfortunately using an arbitrary Sleep() is the only way I've managed to achieve this. The exWaitUntilIdle flag unsurprisingly doesn't do the trick and delay the execution long enough (if at all).
So does anyone have a more robust way of ensuring the createuser is not executed until the Postgres (pg_ctl start) server command is running, idle and ready to accept commands?
Solution 1:[1]
Use ewWaitUntilTerminated flag with -w switch:
Wait for the startup or shutdown to complete. Waiting is the default option for shutdowns, but not startups. ...
pg_ctlreturns an exit code based on the success of the startup or shutdown.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
