-
Notifications
You must be signed in to change notification settings - Fork 45
/
supervisor-config.initd
125 lines (113 loc) · 3.32 KB
/
supervisor-config.initd
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
# chkconfig: 2345 99 01
# description: Supervisord instance for Contrail Config Package
ulimit -c unlimited
. /etc/init.d/functions
function log_success_msg() {
success
}
function log_failure_msg() {
failure
}
PID_FILE=/var/run/supervisord-config.pid
function daemon_start() {
ulimit -s unlimited
ulimit -c unlimited
ulimit -d unlimited
ulimit -v unlimited
ulimit -n 4096
retval=false
socketon=false
if [[ ! -z `ps -ef | grep contrail-discovery | grep -v grep | awk '{print $2}'` ]]; then
pkill -9 -f contrail-discovery
fi
if [[ ! -z `ps -ef | grep irond.jar | grep -v grep | awk '{print $2}'` ]]; then
pkill -9 -f irond.jar
fi
if [[ ! -z `ps -ef | grep contrail-api | grep -v grep | awk '{print $2}'` ]]; then
pkill -9 -f contrail-api
fi
if [[ ! -z `ps -ef | grep contrail-schema | grep -v grep | awk '{print $2}'` ]]; then
pkill -9 -f contrail-schema
fi
if [[ ! -z `ps -ef | grep contrail-svc-monitor | grep -v grep | awk '{print $2}'` ]]; then
pkill -9 -f contrail-svc-monitor
fi
if [[ ! -z `ps -ef | grep contrail-device-manager | grep -v grep | awk '{print $2}'` ]]; then
pkill -9 -f contrail-device-manager
fi
/usr/bin/supervisord -c /etc/contrail/supervisord_config.conf
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
retval=true
lsof | grep -i supervisord_config.sock
if [ $? -eq 0 ]; then
socketon=true
pid=`lsof | grep -i supervisord_config.sock | cut -d' ' -f3`
if [ "x$pid" != "x" ] ; then
ps uw -p $pid
fi
fi
fi
if [[ "retval" == true ]]; then
echo "supervisor-config start failed. checking lsof.."
if [[ "socketon" == true ]]; then
echo "Another program listening on same socket"
fi
else
echo -n "Started Supervisor Daemon for Contrail Config Package"
fi
}
function daemon_stop() {
if [ -e /tmp/supervisord_config.sock ]; then
supervisorctl -s unix:///tmp/supervisord_config.sock stop all
supervisorctl -s unix:///tmp/supervisord_config.sock shutdown
else
supervisorctl -s unix:///var/run/supervisord_config.sock stop all
supervisorctl -s unix:///var/run/supervisord_config.sock shutdown
fi
if [ -f $PID_FILE ]; then
kill `cat $PID_FILE`
rm -f $PID_FILE
fi
if [ -e "/etc/contrail/supervisord_config_files/contrail-api.kill" ]
then
# replacing supervisor_killall
pkill -9 -f 'irond.jar'
pkill -9 -f 'svc-monitor.py'
pkill -9 -f 'to_bgp.py'
pkill -9 -f 'vnc_cfg_api_server.py'
pkill -9 -f 'disc_server_zk.py'
fi
}
daemon_status() {
declare -f -F status > /dev/null
if [ "$?" = "0" ]; then
status -p $PID_FILE supervisord
else
declare -f -F status_of_proc > /dev/null
if [ "$?" = "0" ]; then
status_of_proc -p $PID_FILE supervisord config
fi
fi
}
daemon_status_q() {
daemon_status >/dev/null 2>&1
}
case $1 in
start)
daemon_status_q && exit 0
daemon_start
;;
stop)
daemon_status_q || exit 0
daemon_stop
;;
restart)
daemon_stop
daemon_start
;;
status)
daemon_status
;;
esac