6 # description: reverse-proxy and load-balancer
9 # Source function library
10 . /etc/rc.d/init.d/functions
13 . /etc/sysconfig/network
15 # List of instances to start.
16 POUND_INSTANCES="pound"
19 [ -f /etc/sysconfig/pound ] && . /etc/sysconfig/pound
21 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
24 msg_network_down pound
33 pound -c -f /etc/pound/$instance.yaml > /dev/null
36 # check if the $1 instance is up
39 local pidfile=/var/run/pound/$instance.pid
40 [ -f $pidfile ] || return 1
41 local pid=$(cat $pidfile)
42 kill -0 $pid 2>/dev/null
46 # check if any of the instances are up
48 local ret=1 instance pidfile
50 for pidfile in /var/run/pound/*.pid; do
51 [ -f "$pidfile" ] || continue
52 instance=${pidfile#/var/run/pound/}
53 instance=${instance%.pid}
54 is_up $instance || continue
61 # check if all of the instances are up
63 local ret=1 instance pidfile
65 for pidfile in /var/run/pound/*.pid; do
66 [ -f "$pidfile" ] || continue
67 instance=${pidfile#/var/run/pound/}
68 instance=${instance%.pid}
69 is_up $instance && continue
77 local ret started=0 found=0 instance
79 # Check if the service is already running?
81 msg_already_running "Pound"
85 msg_starting "Pound"; started
86 for instance in $POUND_INSTANCES; do
87 show "Starting Pound instance %s" "$instance"
88 if is_up $instance; then
93 PIDFILE=/var/run/pound/$instance.pid
94 start-stop-daemon --start \
95 --exec /usr/sbin/pound \
96 --pidfile $PIDFILE -- -v -f /etc/pound/$instance.yaml -p $PIDFILE
99 if [ $ret -eq 0 ]; then
109 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pound
115 msg_not_running "Pound"
120 msg_stopping "Pound"; started
121 for instance in $POUND_INSTANCES; do
122 is_up $instance || continue
123 show "Stopping Pound instance %s" "$instance"; busy
124 killproc --pidfile pound/$instance.pid pound
127 rm -f /var/lock/subsys/pound > /dev/null 2>&1
128 rm -f /var/run/pound/$instance.pid > /dev/null 2>&1
135 # make up list of configured and up instances
137 show "Checking configuration"; busy
138 for instance in $POUND_INSTANCES; do
139 # skip ones whose config fails
140 configtest $instance || continue
141 list="$list $instance"
144 # nothing left or never was
145 if [ -z "$list" ]; then
149 POUND_INSTANCES=$list
160 if [ ! -f /var/lock/subsys/pound ]; then
161 msg_not_running "Pound"
171 local stat=1 pidfile instance
173 nls "Configured Pound instances:"
174 echo " $POUND_INSTANCES"
175 nls "Currently active Pound instances:"
176 for pidfile in /var/run/pound/*.pid; do
177 [ -f "$pidfile" ] || continue
178 instance=${pidfile#/var/run/pound/}
179 instance=${instance%.pid}
180 is_up $instance && echo -n " $instance($(cat $pidfile))"
187 if [ "$1" != status -a "$2" ]; then
192 # See how we were called.
210 if [ -f /var/lock/subsys/pound ]; then
211 for instance in $POUND_INSTANCES; do
212 show "Rotating Pound logs for %s instance" $instance
213 killproc --pidfile /var/run/pound/$instance.pid pound -USR1
215 if [ $ret != 0 ]; then
220 msg_not_running "Pound"
228 msg_usage "$0 {start|stop|restart|try-restart|force-reload|flush-logs|status} [INSTANCE NAMES]"