* Shut down PostgreSQL cleanly.
svn path=/nixos/branches/upstart-0.6/; revision=18236
This commit is contained in:
parent
18f2d75275
commit
06fcb121fb
@ -118,19 +118,38 @@ in
|
|||||||
|
|
||||||
startOn = "started ${startDependency}";
|
startOn = "started ${startDependency}";
|
||||||
|
|
||||||
environment = { TZ = config.time.timeZone; };
|
environment =
|
||||||
|
{ TZ = config.time.timeZone;
|
||||||
|
PGDATA = cfg.dataDir;
|
||||||
|
};
|
||||||
|
|
||||||
preStart =
|
preStart =
|
||||||
''
|
''
|
||||||
|
# Initialise the database.
|
||||||
if ! test -e ${cfg.dataDir}; then
|
if ! test -e ${cfg.dataDir}; then
|
||||||
mkdir -m 0700 -p ${cfg.dataDir}
|
mkdir -m 0700 -p ${cfg.dataDir}
|
||||||
chown -R postgres ${cfg.dataDir}
|
chown -R postgres ${cfg.dataDir}
|
||||||
${run} -c '${postgresql}/bin/initdb -D ${cfg.dataDir} -U root'
|
${run} -c '${postgresql}/bin/initdb -U root'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp -f ${pkgs.writeText "pg_hba.conf" cfg.authentication} ${cfg.dataDir}/pg_hba.conf
|
cp -f ${pkgs.writeText "pg_hba.conf" cfg.authentication} ${cfg.dataDir}/pg_hba.conf
|
||||||
|
|
||||||
|
# We'd like to use the `-w' flag here to wait until the
|
||||||
|
# database is up, but it requires a `postgres' user to
|
||||||
|
# exist. And we can't call `createuser' before the
|
||||||
|
# database is running.
|
||||||
|
${run} -c '${postgresql}/bin/pg_ctl start'
|
||||||
|
|
||||||
|
# So wait until the server is running.
|
||||||
|
while ! ${run} -c '${postgresql}/bin/pg_ctl status'; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
exec = "${run} -c '${postgresql}/bin/postgres -D ${cfg.dataDir} ${toString flags}'";
|
postStop =
|
||||||
|
''
|
||||||
|
${run} -c '${postgresql}/bin/pg_ctl stop -m fast'
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user