-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcontrol.sh
executable file
·59 lines (51 loc) · 1.06 KB
/
control.sh
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
#!/bin/bash
PROGRAM=gibbon
cmd=$1
THIS_DIR=$(dirname $(readlink -f $0) )
function start()
{
sleep 3
supervisord -c $THIS_DIR/etc/supervisord.conf
[ $? -ne 0 ] && { echo "start supervisord failed"; exit 1; }
retry=0
while [ $retry -lt 5 ]; do
supervisorctl -c $THIS_DIR/etc/supervisord.conf status $PROGRAM |grep RUNNING >/dev/null
[ $? -eq 0 ] && { break; }
retry=$(($retry+1))
sleep 1
done
[ $? -ge 5 ] && { echo "$PROGRAM server not in running status"; return 1; }
return 0
}
function stop()
{
supervisorctl -c $THIS_DIR/etc/supervisord.conf stop $PROGRAM >/dev/null 2>&1
sleep 2
supervisorctl -c $THIS_DIR/etc/supervisord.conf shutdown >/dev/null 2>&1
sleep 2
pid=$(ps axf|grep supervisord |grep $PROGRAM|awk '{print $1}')
[ $? -eq 0 ] && { kill -9 $pid; }
pid=$(ps axf|grep $PROGRAM |grep -v 'ps axf'|awk '{print $1}')
[ $? -eq 0 ] && { kill -9 $pid; }
return 0
}
function restart()
{
stop
start
}
case $cmd in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
RET=2
esac
exit $RET