3 # pgpool This is the init script for starting up pgpool
6 # description: Pgpool - a connection pooling/replication server for PostgreSQL
8 # pidfile: /var/run/pgpool.pid
9 # config: /etc/pgpool.conf
11 # Source function library
12 . /etc/rc.d/init.d/functions
15 . /etc/sysconfig/network
17 PGPOOL_BIN=/usr/bin/pgpool
20 [ -f /etc/sysconfig/pgpool ] && . /etc/sysconfig/pgpool
22 # Check that networking is up.
23 if is_yes "${NETWORKING}"; then
24 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
25 msg_network_down pgpool
32 if [ ! -f $PGPOOLLOG ]; then
38 # Check if the service is already running?
39 if [ ! -f /var/lock/subsys/pgpool ]; then
41 rm -f $PGPOOLPID > /dev/null 2>&1
42 start-stop-daemon -S -x $PGPOOL_BIN -c $PGPOOLUID:$PGPOOLGID \
43 -- -f $PGPOOLCONF -a $PGPOOLHBA $OPTS >> $PGPOOLLOG 2>&1
45 pid_num=`pidof -s $PGPOOL_BIN` # FIXME: this does not restrict the owner
47 echo "Master PID number $pid_num" >> $PGPOOLLOG
48 echo -n $pid_num > $PGPOOLPID
49 touch /var/lock/subsys/pgpool
55 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pgpool
57 msg_already_running pgpool
64 if [ -f /var/lock/subsys/pgpool ]; then
67 $PGPOOL_BIN -f $PGPOOLCONF stop >> $PGPOOLLOG 2>&1
69 rm -f /var/lock/subsys/pgpool /var/run/pgpool.pid >/dev/null 2>&1
75 msg_not_running pgpool
80 # Stop daemons (don't wait)
81 if [ -f /var/lock/subsys/pgpool ]; then
84 $PGPOOL_BIN -m fast stop >> $PGPOOLLOG 2>&1
86 rm -f /var/lock/subsys/pgpool /var/run/pgpool.pid >/dev/null 2>&1
92 msg_not_running pgpool
97 # See how we were called.
114 if [ -f /var/lock/subsys/pgpool ]; then
116 pgpool switch >> $PGPOOLLOG 2>&1
119 msg_not_running pgpool
128 msg_usage "$0 {start|stop|restart|force-reload|switch|status}"