| #!/bin/sh |
| # |
| # config.rc sample with defaults : |
| # service haproxy |
| # config /etc/haproxy/haproxy.cfg |
| # maxconn 1024 |
| # |
| config="/etc/haproxy/haproxy.cfg" |
| maxconn=1024 |
| |
| bin=/usr/sbin/haproxy |
| cmdline='$bin -D' |
| |
| . $ROOT/sbin/init.d/default |
| |
| 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 |
| function dostop { |
| pids=`pidof -o $$ -- $PNAME` |
| if [ ! -z "$pids" ]; then |
| echo "Asking $PNAME to terminate gracefully..." |
| kill -USR1 $pids |
| fi |
| } |
| |
| main $* |
| |