-
Notifications
You must be signed in to change notification settings - Fork 12
/
dory.init
executable file
·96 lines (81 loc) · 2.05 KB
/
dory.init
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
#!/bin/sh
#
# dory Start/Stop the dory daemon.
#
# chkconfig: 2345 79 20
# description: Dory is a producer daemon for Apache Kafka.
### BEGIN INIT INFO
# Provides: dory
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2345
# Default-Stop: 99
# Short-Description: run dory daemon
# Description: Dory is a producer daemon for Apache Kafka.
### END INIT INFO
PATH=/usr/bin:/bin
DORY=/usr/bin/dory
LOCKFILE=/var/lock/subsys/dory
CONFIG_PATH=/etc/dory/dory_conf.xml
. /etc/rc.d/init.d/functions
. /etc/sysconfig/dory
RETVAL=0
get_dory_pid () {
pgrep -u nobody -f "dory.*--config-path ${CONFIG_PATH}( |$)"
}
case "$1" in
start)
echo -n "Starting dory: "
[ -f "$DORY" ] || exit 1
mkdir -p /var/run/dory
chown nobody /var/run/dory
chgrp nobody /var/run/dory
daemon --user=nobody "$DORY" --daemon --config-path $CONFIG_PATH
RETVAL=$?
echo
[ "$RETVAL" -eq 0 ] && touch "$LOCKFILE"
;;
stop)
echo -n "Shutting down dory: "
PID=$(get_dory_pid)
if [ -z "PID" ]; then
echo dory is not running 1>&2
RETVAL=1
else
kill -TERM "$PID"
i=0
while [ "$i" -lt 20 ] && [ ! -z "$(get_dory_pid)" ]; do
sleep 1
((++i))
done
if [ -z "$(get_dory_pid)" ]; then
RETVAL=0
else
echo Failed to shut down dory 1>&2
kill -9 "$PID" && /usr/bin/logger "Dory failed to shut down cleanly and was killed."
RETVAL=1
fi
fi
echo
[ "$RETVAL" -eq 0 ] && rm -f "$LOCKFILE"
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
status)
PID=$(get_dory_pid)
if [ -n "$PID" ]; then
echo "dory is running with PID $PID"
RETVAL=0
else
echo "dory is not running"
RETVAL=3
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit "$RETVAL"