blob: 295d50a2bbfc7228c1eb42d23c8f11c69ad59624 [file] [log] [blame]
willy tarreau5cbea6f2005-12-17 12:48:26 +01001#!/bin/sh
willy tarreau535ae7a2005-12-17 12:58:00 +01002#
3# config.rc sample with defaults :
4# service haproxy
5# config /etc/haproxy/haproxy.cfg
6# maxconn 1024
7#
8config="/etc/haproxy/haproxy.cfg"
9maxconn=1024
willy tarreau5cbea6f2005-12-17 12:48:26 +010010
11bin=/usr/sbin/haproxy
willy tarreau535ae7a2005-12-17 12:58:00 +010012cmdline='$bin -D'
willy tarreau5cbea6f2005-12-17 12:48:26 +010013
14. $ROOT/sbin/init.d/default
15
willy tarreau535ae7a2005-12-17 12:58:00 +010016if [ -e "$config" ]; then
17 maintfd=`grep '^\([^#]*\)\(listen\|server\)' $config|wc -l`
18else
19 maintfd=0
20fi
21
22maxfd=$[$maxconn*2 + $maintfd]
23if [ $maxfd -lt 100 ]; then
24 maxfd=100;
25fi
26cmdline="$cmdline -n $maxconn -f $config"
27ulimit -n $maxfd
28
29# to get a core when needed, uncomment the following :
30# cd /var/tmp
31# ulimit -c unlimited
32
33# soft stop
willy tarreaubc4e1fb2005-12-17 13:32:07 +010034function do_stop {
willy tarreau5cbea6f2005-12-17 12:48:26 +010035 pids=`pidof -o $$ -- $PNAME`
36 if [ ! -z "$pids" ]; then
willy tarreau535ae7a2005-12-17 12:58:00 +010037 echo "Asking $PNAME to terminate gracefully..."
willy tarreau5cbea6f2005-12-17 12:48:26 +010038 kill -USR1 $pids
willy tarreau8337c6b2005-12-17 13:41:01 +010039 echo "(use kill $pids to stop immediately)."
40 fi
41}
42
43# dump status
44function do_status {
45 pids=`pidof -o $$ -- $PNAME`
46 if [ ! -z "$pids" ]; then
47 echo "Dumping $PNAME status in logs."
48 kill -HUP $pids
49 else
50 echo "Process $PNAME is not running."
willy tarreau5cbea6f2005-12-17 12:48:26 +010051 fi
52}
53
54main $*
55