summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-db/postgresql-server/files/postgresql.init-8.2')
-rw-r--r--dev-db/postgresql-server/files/postgresql.init-8.243
1 files changed, 29 insertions, 14 deletions
diff --git a/dev-db/postgresql-server/files/postgresql.init-8.2 b/dev-db/postgresql-server/files/postgresql.init-8.2
index ef06024..255f0d6 100644
--- a/dev-db/postgresql-server/files/postgresql.init-8.2
+++ b/dev-db/postgresql-server/files/postgresql.init-8.2
@@ -1,5 +1,5 @@
#!/sbin/runscript
-# Copyright 1999-2007 Gentoo Foundation
+# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
@@ -31,25 +31,40 @@ start() {
rm -f "$PGDATA/postmaster.pid"
fi
- start-stop-daemon --start \
- --pidfile "${PGDATA}/postmaster.pid" \
- --chuid ${PGUSER}:${PGGROUP} \
- --exec /usr/lib/postgresql-8.2/bin/postmaster \
- -- \
- -D "${PGDATA}" \
- --silent-mode=true \
- ${PGOPTS}
+ su -l ${PGUSER} \
+ -c "env PGDATA=\"${PGDATA}\" /usr/lib/postgresql-8.2/bin/pg_ctl start -w -o '--silent-mode=true ${PGOPTS}'"
eend $?
}
stop() {
- ebegin "Stopping PostgreSQL"
- # Note: we have to do --oknodo here, otherwise it will always fail
- # when there are open transactions. This bug has been corrected
- # in baselayout-1.13.0_alpha8.
+ ebegin "Stopping PostgreSQL (this can take up to $(( ${WAIT_FOR_DISCONNECT} + ${WAIT_FOR_CLEANUP} )) seconds)"
+
+ start-stop-daemon --stop --pidfile "${PGDATA}/postmaster.pid" \
+ --retry -TERM/${WAIT_FOR_DISCONNECT}
+ [ $? -eq 0 ] && eend $? && exit
+
+ ewarn "Some clients did not disconnect within ${WAIT_FOR_DISCONNECT} seconds."
+ ewarn "Going to shutdown the server anyway."
+
+ start-stop-daemon --stop --pidfile "${PGDATA}/postmaster.pid" \
+ --retry -INT/${WAIT_FOR_CLEANUP}
+ [ $? -eq 0 ] && eend $? && exit
+
+ if [ ${WAIT_FOR_QUIT} -eq 0 ] ; then
+ eerror "Server did not shut down and sending the SIGQUIT has been disabled."
+ eend $?
+ fi
+
+ ewarn "Shutting down the server gracefully failed."
+ ewarn "Forcing it to shutdown which leads to a recover-run on next startup."
+
start-stop-daemon --stop --pidfile "${PGDATA}/postmaster.pid" \
- --retry -TERM/${WAIT_FOR_DISCONNECT}/-INT/${WAIT_FOR_CLEANUP}/-QUIT --oknodo
+ --retry -QUIT/${WAIT_FOR_QUIT}
+
+ [ $? -eq 0 ] && eend $? && exit
+
+ eerror "Forced shutdown failed!!! Something is wrong with your system, please take care of it manually."
eend $?
}