postgresql - Inno Setup - 等待 Postgres 数据库启动

标签 postgresql inno-setup

在下面的示例中,我想延迟执行 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/

相关文章:

java - 在外部 Postgres 数据库更新时触发 java 事件

javascript - Postgres : No payload received when using pg_notify with `node-postgres` Javascript library

postgresql - PostgreSQL 中的时间序列 - 列表更改

node.js - NodeJS Sequelize : Association with alias [alias] does not exist on [model]

inno-setup - inno setup bmp 图像出现在一个页面上

c# - 使用数据库创 build 置文件

windows - InnoSetup - 如何将 setup.exe 变成 875kB?以便用户更快地下载它并且在下载时它会下载另一个?

iis - Inno Setup CreateOleObject ('IISNamespace')在 Windows Server 2012 上引发异常