SOURCES: postgresql.init - implement reload without server restart...

qboosh qboosh at pld-linux.org
Tue Feb 19 22:30:01 CET 2008


Author: qboosh                       Date: Tue Feb 19 21:30:01 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- implement reload without server restart, force-reload not trying to start dead servers, try-restart starting only servers which should have been running

---- Files affected:
SOURCES:
   postgresql.init (1.74 -> 1.75) 

---- Diffs:

================================================================
Index: SOURCES/postgresql.init
diff -u SOURCES/postgresql.init:1.74 SOURCES/postgresql.init:1.75
--- SOURCES/postgresql.init:1.74	Tue Feb 19 22:18:27 2008
+++ SOURCES/postgresql.init	Tue Feb 19 22:29:55 2008
@@ -164,6 +164,7 @@
 	pgsubsys
 }
 
+RETVAL=0
 # See how we were called.
 # Every action is performed for all given (all configured by default)
 # db clusters.
@@ -191,23 +192,36 @@
 	stop
 	start
 	;;
-  reload|force-reload)
+  reload|force-reload|try-restart)
+	if [ "$action" = "reload" ]; then
+		# "reload" must not restart service - so let it reload only what's possible
+		pgctlact="reload"
+	else
+		pgctlact="restart"
+	fi
 	for pgdir in $DB_CLUSTERS; do
 		pgstatus "$pgdir"
 		if [ "$PG_STATUS" = "not running" ]; then
 			msg_not_running "PostgreSQL $pgdir"
+			if [ "$action" != "try-restart" ]; then
+				RETVAL=7
+			fi
 		else
 			msg_reloading "PostgreSQL $pgdir"
 			busy
 			# is postgresql really alive?
 			if ps -p "$PG_PID" >/dev/null; then
-				TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -D $pgdir restart 2>&1 >/dev/null"
+				TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -D $pgdir $pgctlact 2>&1 >/dev/null"
 					pgstatus "$pgdir"
 				if [ "$PG_STATUS" = "running" ]; then
 					ok
 				else
 					fail
 				fi
+			elif [ "$action" != "try-restart" ]; then
+				# postgresql died and pg_ctl has misinformed us about
+				# the status - i.e. service is actually not running
+				RETVAL=7
 			else
 				# postgresql died and pg_ctl has misinformed us about
 				# the status; remove pid file and start it again
@@ -241,4 +255,4 @@
 	exit 3
 esac
 
-exit 0
+exit $RETVAL
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/postgresql.init?r1=1.74&r2=1.75&f=u



More information about the pld-cvs-commit mailing list