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.cfg > /dev/null
37 # check if the $1 instance is up
40 local pidfile=/var/run/pound/$instance.pid
41 [ -f $pidfile ] || return 1
42 local pid=$(cat $pidfile)
43 kill -0 $pid 2>/dev/null
47 # check if any of the instances are up
49 local ret=1 instance pidfile
51 for pidfile in /var/run/pound/*.pid; do
52 [ -f "$pidfile" ] || continue
53 instance=${pidfile#/var/run/pound/}
54 instance=${instance%.pid}
55 is_up $instance || continue
62 # check if all of the instances are up
64 local ret=1 instance pidfile
66 for pidfile in /var/run/pound/*.pid; do
67 [ -f "$pidfile" ] || continue
68 instance=${pidfile#/var/run/pound/}
69 instance=${instance%.pid}
70 is_up $instance && continue
78 local ret started=0 found=0 instance
80 # Check if the service is already running?
82 msg_starting "Pound"; started
83 for instance in $POUND_INSTANCES; do
84 show "Starting Pound instance %s" "$instance"
85 if is_up $instance; then
90 PIDFILE=/var/run/pound/$instance.pid
91 start-stop-daemon --start \
92 --exec /usr/sbin/pound \
93 --pidfile $PIDFILE -- -v -f /etc/pound/$instance.cfg -p $PIDFILE
96 if [ $ret -eq 0 ]; then
106 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pound
108 msg_already_running "Pound"
116 msg_stopping "Pound"; started
117 for instance in $POUND_INSTANCES; do
118 is_up $instance || continue
119 show "Stopping Pound instance %s" "$instance"; busy
120 killproc --pidfile pound/$instance.pid pound
123 rm -f /var/lock/subsys/pound > /dev/null 2>&1
124 rm -f /var/run/pound/$instance.pid > /dev/null 2>&1
126 msg_not_running "Pound"
134 # make up list of configured and up instances
136 show "Checking configuration"; busy
137 for instance in $POUND_INSTANCES; do
138 # skip ones whose config fails
139 configtest $instance || continue
140 list="$list $instance"
143 # nothing left or never was
144 if [ -z "$list" ]; then
148 POUND_INSTANCES=$list
159 if [ -f /var/lock/subsys/pound ]; then
163 msg_not_running "Pound"
169 local stat=1 pidfile instance
171 nls "Configured Pound instances:"
172 echo " $POUND_INSTANCES"
173 nls "Currently active Pound instances:"
174 for pidfile in /var/run/pound/*.pid; do
175 [ -f "$pidfile" ] || continue
176 instance=${pidfile#/var/run/pound/}
177 instance=${instance%.pid}
178 is_up $instance && echo -n " $instance($(cat $pidfile))"
185 if [ "$1" != status -a "$2" ]; then
190 # See how we were called.
208 if [ -f /var/lock/subsys/pound ]; then
209 for instance in $POUND_INSTANCES; do
210 show "Rotating Pound logs for %s instance" $instance
211 killproc --pidfile /var/run/pound/$instance.pid pound -USR1
213 if [ $ret != 0 ]; then
218 msg_not_running "Pound"
226 msg_usage "$0 {start|stop|restart|try-restart|force-reload|flush-logs|status} [INSTANCE NAMES]"