-
Notifications
You must be signed in to change notification settings - Fork 11
/
carbon-relay
81 lines (68 loc) · 1.73 KB
/
carbon-relay
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
#!/bin/sh
# Initscript for carbon-relay processes
# Jason Dixon <jason@dixongroup.net>
#
# You must set the variables below. The
# INSTANCES variable should be set to the
# number of carbon-relay instances you have
# configured in your carbon.conf. Note that
# they must be numerically indexed from 1.
# (e.g. [relay:1], [relay:2], [relay:3]
PID_DIR=/opt/graphite/storage
DAEMON=/opt/graphite/bin/carbon-relay.py
NAME=carbon-relay
INSTANCES=2
set -e
test -x $DAEMON || exit 0
case "$1" in
start)
for INSTANCE in $(seq 1 $INSTANCES); do
echo -n "Starting ${NAME}-${INSTANCE}: "
if start-stop-daemon --start --quiet --pidfile "${NAME}-${INSTANCE}.pid" --exec $DAEMON start 1>/dev/null -- --instance=${INSTANCE}
then
echo "succeeded"
else
echo "failed"
fi
done
${0} status
;;
stop)
for INSTANCE in $(seq 1 $INSTANCES); do
echo -n "Stopping ${NAME}-${INSTANCE}: "
$DAEMON stop --instance=${INSTANCE} 1>/dev/null
echo "stopped"
done
exit 0
;;
restart)
${0} stop
${0} start
;;
status)
for INSTANCE in $(seq 1 $INSTANCES); do
if [ -f "${PID_DIR}/${NAME}-${INSTANCE}.pid" ]; then
PID=`cat "${PID_DIR}/${NAME}-${INSTANCE}.pid"`
echo -n "${NAME}-${INSTANCE} (pid: $PID): "
if ps -p $PID >/dev/null; then
echo "running"
else
echo "failed"
fi
else
echo "${NAME}-${INSTANCE} not running"
fi
done
for INSTANCE in $(seq 1 $INSTANCES); do
if [ ! -f "${PID_DIR}/${NAME}-${INSTANCE}.pid" ]; then
exit 1
fi
done
exit 0
;;
*)
echo "Usage: /etc/init.d/${NAME} {start|stop|restart|status}" >%2
exit 1
;;
esac
exit 0