mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-28 01:43:15 +00:00
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:
commit
efdb8a10ed
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user