mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-29 06:45:54 +03:00
Use PostgreSQL 9.3's pg_isready
to wait for connectivity
The postgresql module has a postStart section that waits for a database to accept connections before continuing. However, this assumes various properties about the database - specifically the database user and (implicitly) the database name. This means that for old installations, this command fails because there is no 'postgres' user, and the service never starts. While 7deff39 does create the 'postgres' user, a better solution is to use `pg_isready`, who's sole purpose is to check if the database is accepting connections. This has no dependency on users, so should be more robust.
This commit is contained in:
parent
7de29bd26f
commit
e206684110
@ -226,7 +226,7 @@ in
|
||||
# Wait for PostgreSQL to be ready to accept connections.
|
||||
postStart =
|
||||
''
|
||||
while ! su -s ${pkgs.stdenv.shell} postgres -c 'psql postgres -c ""' 2> /dev/null; do
|
||||
while ! ${pkgs.postgresql93}/bin/pg_isready > /dev/null; do
|
||||
if ! kill -0 "$MAINPID"; then exit 1; fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user