-
Notifications
You must be signed in to change notification settings - Fork 22
/
zsupervisor
executable file
·103 lines (88 loc) · 2.29 KB
/
zsupervisor
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
#! /usr/bin/env bash
##############################################################################
#
# Copyright (C) Zenoss, Inc. 2013, all rights reserved.
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################
# zsupervisor is a pass through to supervisorctl.
echoerr() { echo "$@" 1>&2; }
if [ -z "$ZENHOME" ] ; then
echoerr "ERROR: '$ZENHOME' is not set."
echoerr "This is usually caused by executing this command as root rather than \
as the zenoss user. Either define '$ZENHOME' or run this command as a \
different user."
exit 1
fi
PIDFILE=$ZENHOME/var/supervisord.pid
CONF_FILE=$ZENHOME/etc/zsupervisor.conf
SUPERVISORCTL=`which supervisorctl`
if [ -z "$SUPERVISORCTL" ];then
echoerr "supervisorctl not in path."
exit 1
fi
genconf(){
cat - <<GENCONF
[supervisord]
nodaemon=false
logfile = log/supervisord.log
pidfile = var/supervisord.pid
[unix_http_server]
file=var/supervisor.sock
[supervisorctl]
serverurl=unix://var/supervisor.sock ; use a unix:// URL for a unix socket
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[include]
files = supervisor/*.conf
GENCONF
}
help(){
cat - <<HELP
HELP
}
zsuperviser_run() {
case "$CMD" in
genconf)
genconf
;;
startup)
if [ ! -f "$PIDFILE" ];then
cd $ZENHOME
supervisord -c $CONF_FILE --pidfile=$PIDFILE -d $ZENHOME -i zenoss
EXITCODE=$?
if [ ${EXITCODE} == 0 ];then
echo "Started supervisord"
else
echo "Failed to start supervisord"
exit ${EXITCODE}
fi
else
echo "Already started"
fi
;;
help)
help
;;
*)
if [ ! -f "$CONF_FILE" ];then
echoerr "supervisor config not found."
exit 1
fi
if [ ! -f "$PIDFILE" ];then
if [ "$CMD" == "shutdown" ]; then
exit 0
fi
echoerr "supervisord not running"
exit 2
fi
cd $ZENHOME
$SUPERVISORCTL -c $CONF_FILE "$@"
;;
esac
exit
}
CMD=$1
zsuperviser_run "$@"