From e3c19d01fffefd9fe7fbf98379eea5968c35cb11 Mon Sep 17 00:00:00 2001 From: Yugo Nagata Date: Wed, 28 May 2014 13:37:42 +0900 Subject: [PATCH] Fix pgpool.init's long-standing bug of stop/restart failure In previous, pgpool.init uses killproc for stopping pgpool, but there are several problems; (1) some child processes can be left since the parent process restarts killed processes; (2) when pgpool has connection from clients, pgpool can't stop until connection closed; (3) restart() fails for these reasons. In the new version, "pgpool -m fast stop" is used in stop(). The problems above are resolved and restart() also works well, even when watchdog enabled. In addition, exit code according with LSB is considered, try-restart option is implemented, and the old switch option is removed. Original patch contributed by Ryan DeShone and modified by Yugo Nagata. See [pgpool-hackers: 239][pgpool-hackers: 512]. --- redhat/pgpool.init | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/redhat/pgpool.init b/redhat/pgpool.init index d2aaf05e8..b802a9b8c 100755 --- a/redhat/pgpool.init +++ b/redhat/pgpool.init @@ -15,10 +15,11 @@ # v2.2.5 Devrim GUNDUZ # - Fix logging. # -# v3.0.0 Yugo Nagata -# - Fix stop and reload functions -# - Fix exit code according with LSB +# v3.3.3 Ryan Deshone and Yugo Nagata +# - Update stop and reload to use pgpool commands properly +# - Removed "switch" as pgpool no longer suppports that command # - Add try-restart option +# - Fix exit code according with LSB # Source function library. INITD=/etc/rc.d/init.d @@ -60,8 +61,8 @@ PGPOOLLOG=/var/log/pgpool.log lockfile="/var/lock/subsys/${NAME}" pidfile="$PGPOOLPIDDIR/pgpool.pid" -# Override defaults from /etc/sysconfig/pgpool if file is present -[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME} +# Import configuration from /etc/sysconfig, if it exists +[ -f /etc/sysconfig/${NAME} ] && . /etc/sysconfig/${NAME} test -x $PGPOOLDAEMON || exit 5 @@ -78,13 +79,13 @@ fi if [ ! -x $PGPOOLLOG ] then touch $PGPOOLLOG - chown $PGPOOLUSER: $PGPOOLLOG + chown ${PGPOOLUSER}: $PGPOOLLOG fi if [ ! -d $PGPOOLPIDDIR ] then mkdir $PGPOOLPIDDIR - chown $PGPOOLUSER: $PGPOOLPIDDIR + chown ${PGPOOLUSER}: $PGPOOLPIDDIR fi script_result=0 @@ -123,7 +124,6 @@ stop(){ then $SU -l $PGPOOLUSER -c "$PGPOOLDAEMON -f $PGPOOLCONF -m fast stop" >> "$PGPOOLLOG" 2>&1 < /dev/null - #if [ -n "`pidofproc -p $pidfile $PGPOOLDAEMON`" ] RETVAL=$? if [ $RETVAL -eq 0 ] then @@ -145,7 +145,7 @@ restart(){ } reload(){ - PGPOOL_RELOAD=$"Reloading ${NAME}: " + PGPOOL_RELOAD=$"Reloading ${NAME} configuration: " echo -n "$PGPOOL_RELOAD" if [ -n "`pidofproc -p $pidfile $PGPOOLDAEMON`" ] -- 2.39.5