diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-27 16:59:38 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-27 16:59:38 +0000 |
commit | 8f5500e6bdb4d42ea9620b0f515671be7d681bf6 (patch) | |
tree | ee566993694a99187df4837355addbf633ae3372 /contrib/start-scripts/osx/PostgreSQL | |
parent | 0e3f0cbddcb6da390c1accc5fc6af4eedd33b6a2 (diff) | |
download | postgresql-8f5500e6bdb4d42ea9620b0f515671be7d681bf6.tar.gz |
Make it reasonably safe to use pg_ctl to start the postmaster from a boot-time
script.
To do this, have pg_ctl pass down its parent shell's PID in an environment
variable PG_GRANDPARENT_PID, and teach CreateLockFile() to disregard that PID
as a false match if it finds it in postmaster.pid. This allows us to cope
with one level of postgres-owned shell process even with pg_ctl in the way,
so it's just as safe as starting the postmaster directly. You still have to
be careful about how you write the initscript though.
Adjust the comments in contrib/start-scripts/ to not deprecate use of
pg_ctl. Also, fix the ROTATELOGS option in the OSX script, which was
indulging in exactly the sort of unsafe coding that renders this fix
pointless :-(. A pipe inside the "sudo" will probably result in more
than one postgres-owned process hanging around.
Diffstat (limited to 'contrib/start-scripts/osx/PostgreSQL')
-rwxr-xr-x | contrib/start-scripts/osx/PostgreSQL | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/start-scripts/osx/PostgreSQL b/contrib/start-scripts/osx/PostgreSQL index dc826837a3..65150d0fd5 100755 --- a/contrib/start-scripts/osx/PostgreSQL +++ b/contrib/start-scripts/osx/PostgreSQL @@ -68,9 +68,9 @@ ROTATESEC="604800" # The path that is to be used for the script PATH="$prefix/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" -# What to use to start up the postmaster (we do NOT use pg_ctl for this, -# as it adds no value and can cause the postmaster to misrecognize a stale -# lock file) +# What to use to start up the postmaster. (If you want the script to wait +# until the server has started, you could use "pg_ctl start -w" here. +# But without -w, pg_ctl adds no value.) DAEMON="$prefix/bin/postmaster" # What to use to shut down the postmaster @@ -85,7 +85,7 @@ StartService () { if [ "${POSTGRESQL:=-NO-}" = "-YES-" ]; then ConsoleMessage "Starting PostgreSQL database server" if [ "${ROTATELOGS}" = "1" ]; then - sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' 2>&1 | ${LOGUTIL} '${PGLOG}' ${ROTATESEC} &" + sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' &" 2>&1 | ${LOGUTIL} '${PGLOG}' ${ROTATESEC} & else sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' &" >>$PGLOG 2>&1 fi @@ -104,7 +104,7 @@ RestartService () { sudo -u $PGUSER $PGCTL stop -D "$PGDATA" -s -m fast # should match StartService: if [ "${ROTATELOGS}" = "1" ]; then - sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' 2>&1 | ${LOGUTIL} '${PGLOG}' ${ROTATESEC} &" + sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' &" 2>&1 | ${LOGUTIL} '${PGLOG}' ${ROTATESEC} & else sudo -u $PGUSER sh -c "${DAEMON} -D '${PGDATA}' &" >>$PGLOG 2>&1 fi |