Merge branch 'postgresql-user-fix' of git://github.com/ocharles/nixpkgs into fix-new-conduit

Create 'postgres' user and use pg_isready
This commit is contained in:
Shea Levy 2014-04-07 16:37:43 -04:00
commit efdb8a10ed

View File

@ -197,6 +197,7 @@ in
fi
rm -f ${cfg.dataDir}/*.conf
touch "${cfg.dataDir}/.first_startup"
touch "${cfg.dataDir}/postgresql-user-created"
fi
ln -sfn "${configFile}" "${cfg.dataDir}/postgresql.conf"
@ -225,11 +226,16 @@ 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
if ! [ -e ${cfg.dataDir}/postgresql-user-created ]; then
createuser --superuser postgres
touch ${cfg.dataDir}/postgresql-user-created
fi
if test -e "${cfg.dataDir}/.first_startup"; then
${optionalString (cfg.initialScript != null) ''
cat "${cfg.initialScript}" | su -s ${pkgs.stdenv.shell} postgres -c 'psql postgres'