diff options
author | Oliver Charles <ollie@ocharles.org.uk> | 2014-04-06 12:00:02 +0100 |
---|---|---|
committer | Oliver Charles <ollie@ocharles.org.uk> | 2014-04-06 12:38:02 +0100 |
commit | e2066841106a6b89093ab685368742efa4e3c2c1 (patch) | |
tree | e8b863d515acefea36c526aff0d3d490e3e2e50b /nixos/modules/services/databases | |
parent | 7de29bd26f5e514e95d5d261c08f3029337eecb3 (diff) | |
download | nixlib-e2066841106a6b89093ab685368742efa4e3c2c1.tar nixlib-e2066841106a6b89093ab685368742efa4e3c2c1.tar.gz nixlib-e2066841106a6b89093ab685368742efa4e3c2c1.tar.bz2 nixlib-e2066841106a6b89093ab685368742efa4e3c2c1.tar.lz nixlib-e2066841106a6b89093ab685368742efa4e3c2c1.tar.xz nixlib-e2066841106a6b89093ab685368742efa4e3c2c1.tar.zst nixlib-e2066841106a6b89093ab685368742efa4e3c2c1.zip |
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.
Diffstat (limited to 'nixos/modules/services/databases')
-rw-r--r-- | nixos/modules/services/databases/postgresql.nix | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix index 08a9cdd9f5da..ed66c15e304d 100644 --- a/nixos/modules/services/databases/postgresql.nix +++ b/nixos/modules/services/databases/postgresql.nix @@ -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 |