forked from muesli/beehive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeehive.sh
executable file
·76 lines (62 loc) · 2.01 KB
/
beehive.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /bin/sh
### BEGIN INIT INFO
# Provides: beehive
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: beehive daemon
### END INIT INFO
set -e
# /etc/init.d/beehive: start and stop the beehive daemon
umask 022
. /lib/lsb/init-functions
export GOROOT="/usr/local/opt/go"
export PATH="$GOROOT/bin:$PATH"
export GOPATH="/home/beehive/go"
BINARY="$GOPATH/bin/beehive"
PIDFILE="/var/run/beehive.pid"
CONFIG="/home/beehive/beehive.conf"
test -x $BINARY || exit 0
case "$1" in
start)
log_daemon_msg "Starting beehive daemon" "beehive" || true
if start-stop-daemon --start -b --quiet --oknodo -m --pidfile $PIDFILE --exec $BINARY -- -config="$CONFIG"; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
stop)
log_daemon_msg "Stopping beehive daemon" "beehive" || true
if start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
reload|force-reload)
log_daemon_msg "Reloading beehive daemon's configuration" "beehive" || true
if start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE --exec $BINARY ; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
restart)
log_daemon_msg "Restarting beehive daemon" "beehive" || true
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE
if start-stop-daemon --start -b --quiet --oknodo -m --pidfile $PIDFILE --exec $BINARY -- -config="$CONFIG"; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
status)
status_of_proc -p $PIDFILE $BINARY beehive && exit 0 || exit $?
;;
*)
log_action_msg "Usage: /etc/init.d/beehive {start|stop|reload|restart|status}" || true
exit 1
esac
exit 0