]> git.pld-linux.org Git - packages/pgpool-II.git/blob - pgpool.init
- rc-script added
[packages/pgpool-II.git] / pgpool.init
1 #!/bin/sh
2 #
3 # pgpool        This is the init script for starting up pgpool
4 #
5 # chkconfig:    345 85 15
6 # description:  Pgpool - a connection pooling/replication server for PostgreSQL
7 # processname:  pgpool
8 # pidfile:      /var/run/pgpool.pid
9 # config:       /etc/pgpool.conf
10
11 # Source function library
12 . /etc/rc.d/init.d/functions
13
14 # Get network config
15 . /etc/sysconfig/network
16
17 # Get service config
18 [ -f /etc/sysconfig/pgpool ] && . /etc/sysconfig/pgpool
19
20 # Check that networking is up.
21 if is_yes "${NETWORKING}"; then
22         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
23                 msg_network_down pgpool
24                 exit 1
25         fi
26 else
27         exit 0
28 fi
29
30 if [ ! -f $PGPOOLLOG ]; then
31         touch $PGPOOLLOG
32 fi
33
34
35 start() {
36         # Check if the service is already running?
37         if [ ! -f /var/lock/subsys/pgpool ]; then
38                 msg_starting pgpool
39                 rm -f $PGPOOLPID > /dev/null 2>&1
40                 pgpool -f $PGPOOLCONF \
41                         -a $PGPOOLHBA \
42                         $OPTS >> $PGPOOLLOG 2>&1 #< /dev/null
43                 RETVAL=$?
44                 pid_num=`pidof -s /usr/bin/pgpool`
45                 if [ $pid_num ]; then
46                         echo "Master PID number $pid_num" >> $PGPOOLLOG
47                         echo -n $pid_num > $PGPOOLPID
48                         touch /var/lock/subsys/pgpool
49                         ok
50                 else
51                         RETVAL=1
52                         fail
53                 fi
54 #               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pgpool
55         else
56                 msg_already_running pgpool
57         fi
58 }
59
60
61 stop() {
62         # Stop daemons.
63         if [ -f /var/lock/subsys/pgpool ]; then
64                 msg_stopping pgpool
65                 busy
66                 /usr/bin/pgpool stop >> $PGPOOLLOG 2>&1
67 #               killproc --waitforname pgpool --waitfortime 60 pgpool
68                 if [ $? -eq 0 ]; then
69                         rm -f /var/lock/subsys/pgpool /var/run/pgpool.pid >/dev/null 2>&1
70                         ok
71                 else
72                         fail
73                 fi
74         else
75                 msg_not_running pgpool
76         fi
77 }
78
79 RETVAL=0
80 # See how we were called.
81 case "$1" in
82   start)
83         start
84         ;;
85   stop)
86         stop
87         ;;
88   status)
89         status pgpool
90         RETVAL=$?
91         ;;
92   restart)
93         stop
94         start
95         ;;
96   switch)
97         if [ -f /var/lock/subsys/pgpool ]; then
98                 msg_reloading pgpool
99                 pgpool switch >> $PGPOOLLOG 2>&1
100                 RETVAL=$?
101         else
102                 msg_not_running pgpool
103                 RETVAL=7
104         fi
105         ;;
106   *)
107         msg_usage "$0 {start|stop|restart|switch|status}"
108         exit 3
109         ;;
110 esac
111
112 exit $RETVAL
This page took 0.069238 seconds and 3 git commands to generate.