-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMhaproxy
More file actions
60 lines (52 loc) · 846 Bytes
/
Mhaproxy
File metadata and controls
60 lines (52 loc) · 846 Bytes
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
56
57
58
59
#!/bin/bash
#
#description:
#Mhaproxy This is the script to manage haproxy start or stop or restart
#
#### BEGIN INFO
# Provides: maycap
# Required-Start: null
# Should-Start: null
# version:1.0
# date:2014-6-11
### END INFO
set -e
HADIR=/opt/haproxy
HANAME=haproxy
DAEMON=$HADIR/sbin/$HANAME
CONFIG=$HADIR/$HANAME.cfg
PIDFILE=$HADIR/$HANAME.pid
DESC="HAProxy daemon"
test -x $DAEMON || exit 0
start(){
echo -n "Starting $DESC:$HANAME"
$DAEMON -f $CONFIG
echo "."
}
stop(){
echo -n "Stopping $DESC:$HANAME"
haproxy_pid=`cat $PIDFILE`
kill $haproxy_pid
echo "."
}
restart(){
echo -n "Restarting $DESC:$HANAME"
$DAEMON -f $CONFIG -p $PIDFILE -sf $(cat $PIDFILE)
echo "."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage:$HANAME{start|stop|restart}" >&2
exit 1
;;
esac
exit 0