forked from riemann/riemann-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathriemann-health.init_example
68 lines (64 loc) · 1.38 KB
/
riemann-health.init_example
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
#!/bin/bash
### BEGIN INIT INFO
# Provides: riemann-health
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Riemann health reporter
# Description: The Riemann health reporter.
### END INIT INFO
DESC="Riemann health"
NAME=riemann_tools_health
LOGFILE=/var/log/riemann/$NAME.log
PIDFILE=/var/run/$NAME.pid
DAEMON=riemann-health
DAEMON_ARGS="--host 10.0.2.239 --event-host $(hostname -s) --tag health --tag production --daemon --pidfile $PIDFILE --logfile $LOGFILE"
# Function that starts the daemon/service
do_start()
{
$DAEMON $DAEMON_ARGS >> $LOGFILE 2>&1 || return 1
}
# Function that stops the daemon/service
do_stop()
{
kill `cat $PIDFILE` >> $LOGFILE 2>&1 || return 1
rm -f $PIDFILE
return 0
}
case "$1" in
start)
echo "Starting $DESC..."
do_start
case "$?" in
0) echo -n 'ok' ;;
1) echo -n 'fail' ;;
esac
;;
stop)
echo "Stopping $DESC..."
do_stop
case "$?" in
0) echo -n 'ok' ;;
2) echo -n 'fail' ;;
esac
;;
restart)
echo "Restarting $DESC..."
do_stop
case "$?" in
0)
do_start
case "$?" in
0) echo -n 'ok' ;;
1) echo -n 'failed to start' ;;
esac
;;
1) echo -n 'failed to stop' ;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
exit 3
;;
esac