public inbox for [email protected]
help / color / mirror / Atom feedFrom: Andrew N Golovkov <[email protected]>
To: Jeff Frost <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: init script for pgpool
Date: Fri, 18 Sep 2015 15:40:51 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-pkg-yum>
You forget $pidfile and $PGPOOLUSER and some more comments.
Check script in attach. I'm tested in my centos-6 and pgpool-II-92.
--
Sent via pgsql-pkg-yum mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-pkg-yum
Attachments:
[text/x-shellscript] pgpool.init (4.0K, 2-pgpool.init)
download | inline:
#!/bin/sh
# pgpool This is the init script for starting up pgpool-II
#
# chkconfig: - 74 33
# description: Starts and stops the pgpool daemon
# processname: pgpool
# pidfile: /var/run/pgpool.pid
#
# v1.0.0 Devrim GUNDUZ <[email protected]>
# - Initial version of Red Hat / Fedora init script
#
# v2.2 Devrim GUNDUZ <[email protected]>
# - New and improved version which has some fixes.
#
# v2.2.5 Devrim GUNDUZ <[email protected]>
# - Fix logging.
#
# v2.3 Devrim GUNDUZ <[email protected]>
# - Adjust order of startup and kill, per RH bugzilla #545739.
#
# v3.3.3 Ryan Deshone <[email protected]> and Yugo Nagata <[email protected]>
# - 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
. $INITD/functions
# Get function listing for cross-distribution logic.
TYPESET=`typeset -f|grep "declare"`
# Get config.
. /etc/sysconfig/network
# Check that networking is up.
# We need it for pgpool
[ "${NETWORKING}" = "no" ] && exit 0
# Find the name of the script
NAME=`basename $0`
if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
then
NAME=${NAME:3}
fi
# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
SU=runuser
else
SU=su
fi
# Set defaults for configuration variables
PGPOOLUSER=postgres
PGPOOLENGINE=/usr/pgpool-9.2/bin
PGPOOLDAEMON=$PGPOOLENGINE/pgpool
PGPOOLCONF=/etc/pgpool-II-92/pgpool.conf
PGPOOLPIDDIR=/var/run/pgpool-II-92
PGPOOLLOG=/var/log/pgpool-II-92.log
lockfile="/var/lock/subsys/${NAME}"
pidfile="$PGPOOLPIDDIR/pgpool.pid"
# Import configuration from /etc/sysconfig, if it exists
if [ -r /etc/sysconfig/pgpool-II-92 ]; then
. /etc/sysconfig/pgpool-II-92
fi
test -x $PGPOOLDAEMON || exit 5
# Check whether the config file exists or not
if [ ! -r $PGPOOLCONF ]
then
echo "$PGPOOLCONF not found"
echo_failure
echo
exit 1
fi
# Create the log file if it does not exist
if [ ! -x $PGPOOLLOG ]
then
touch $PGPOOLLOG
chown ${PGPOOLUSER}: $PGPOOLLOG
fi
if [ ! -d $PGPOOLPIDDIR ]
then
mkdir $PGPOOLPIDDIR
chown ${PGPOOLUSER}: $PGPOOLPIDDIR
fi
script_result=0
start(){
PGPOOL_START=$"Starting ${NAME} service: "
echo -n "$PGPOOL_START"
pid="`pidofproc -p "$pidfile" -s "$PGPOOLDAEMON"`"
if [ -n "$pid" ] ; then
echo -n "pgpool is already running with pid $pid "
echo_failure
script_result=1
else
$SU -l $PGPOOLUSER -c "$PGPOOLDAEMON -f $PGPOOLCONF $OPTS & " >> "$PGPOOLLOG" 2>&1 < /dev/null
sleep 2
pid="`pidofproc -p "$pidfile" -s "$PGPOOLDAEMON"`"
if [ -n "$pid" ] ; then
echo_success
touch "$lockfile"
else
echo_failure
script_result=1
fi
fi
echo
}
stop(){
PGPOOL_STOP=$"Stopping ${NAME} service: "
echo -n "$PGPOOL_STOP"
if [ -e "$lockfile" ] ; then
$SU -l $PGPOOLUSER -c "$PGPOOLDAEMON -f $PGPOOLCONF -m fast stop" >> "$PGPOOLLOG" 2>&1 < /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo_success
rm -f "$lockfile"
else
echo_failure
script_result=1
fi
else
echo_success
fi
echo
}
restart(){
stop
start
}
reload(){
PGPOOL_RELOAD=$"Reloading ${NAME} configuration: "
echo -n "$PGPOOL_RELOAD"
pid="`pidofproc -p $pidfile $PGPOOLDAEMON`"
if [ -n "$pid" ] ; then
$SU -l $PGPOOLUSER -c "$PGPOOLDAEMON -f $PGPOOLCONF reload" >> "$PGPOOLLOG" 2>&1 < /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo_success
else
echo_failure
script_result=1
fi
else
echo -n "pgpool is not running "
echo_failure
script_result=1
fi
echo
}
condrestart(){
[ -e "$lockfile" ] && restart
}
condstop(){
[ -e "$lockfile" ] && stop
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p $pidfile pgpool
script_result=$?
;;
restart)
restart
;;
reload|force-reload)
reload
;;
condrestart)
condrestart
;;
condstop)
condstop
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|condstop|reload|force-reload}"
exit 1
esac
exit $script_result
view thread (22+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: init script for pgpool
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox