2005-12-17 11:48:26 +00:00
|
|
|
#!/bin/sh
|
2005-12-17 11:58:00 +00:00
|
|
|
#
|
|
|
|
# config.rc sample with defaults :
|
|
|
|
# service haproxy
|
|
|
|
# config /etc/haproxy/haproxy.cfg
|
|
|
|
# maxconn 1024
|
|
|
|
#
|
|
|
|
config="/etc/haproxy/haproxy.cfg"
|
|
|
|
maxconn=1024
|
2005-12-17 11:48:26 +00:00
|
|
|
|
|
|
|
bin=/usr/sbin/haproxy
|
2005-12-17 11:58:00 +00:00
|
|
|
cmdline='$bin -D'
|
2005-12-17 11:48:26 +00:00
|
|
|
|
|
|
|
. $ROOT/sbin/init.d/default
|
|
|
|
|
2005-12-17 11:58:00 +00:00
|
|
|
if [ -e "$config" ]; then
|
|
|
|
maintfd=`grep '^\([^#]*\)\(listen\|server\)' $config|wc -l`
|
|
|
|
else
|
|
|
|
maintfd=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
maxfd=$[$maxconn*2 + $maintfd]
|
|
|
|
if [ $maxfd -lt 100 ]; then
|
|
|
|
maxfd=100;
|
|
|
|
fi
|
|
|
|
cmdline="$cmdline -n $maxconn -f $config"
|
|
|
|
ulimit -n $maxfd
|
|
|
|
|
|
|
|
# to get a core when needed, uncomment the following :
|
|
|
|
# cd /var/tmp
|
|
|
|
# ulimit -c unlimited
|
|
|
|
|
|
|
|
# soft stop
|
2005-12-17 12:32:07 +00:00
|
|
|
function do_stop {
|
2005-12-17 11:48:26 +00:00
|
|
|
pids=`pidof -o $$ -- $PNAME`
|
|
|
|
if [ ! -z "$pids" ]; then
|
2005-12-17 11:58:00 +00:00
|
|
|
echo "Asking $PNAME to terminate gracefully..."
|
2005-12-17 11:48:26 +00:00
|
|
|
kill -USR1 $pids
|
2005-12-17 12:41:01 +00:00
|
|
|
echo "(use kill $pids to stop immediately)."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# dump status
|
|
|
|
function do_status {
|
|
|
|
pids=`pidof -o $$ -- $PNAME`
|
|
|
|
if [ ! -z "$pids" ]; then
|
|
|
|
echo "Dumping $PNAME status in logs."
|
|
|
|
kill -HUP $pids
|
|
|
|
else
|
|
|
|
echo "Process $PNAME is not running."
|
2005-12-17 11:48:26 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main $*
|
|
|
|
|