File: init.haproxy

package info (click to toggle)
haproxy 1.7.5-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,364 kB
  • ctags: 8,494
  • sloc: ansic: 92,976; xml: 1,754; sh: 1,227; python: 1,005; makefile: 831; perl: 550
file content (55 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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 do_stop {
   pids=`pidof -o $$ -- $PNAME`
   if [ ! -z "$pids" ]; then
      echo "Asking $PNAME to terminate gracefully..."
      kill -USR1 $pids
      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."
   fi
}

main $*