-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathnimbus-control.erb
64 lines (51 loc) · 1.53 KB
/
nimbus-control.erb
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
#!/bin/sh
# Setup basic path information.
LOG_OUT="<%=File.join(@log_dir,"nimbus.out")%>"
LOG_ERR="<%=File.join(@log_dir,"nimbus.err")%>"
HOME_DIR="<%=@install_dir%>"
JAVA_HOME="<%=@java_home%>"
CMD="$HOME_DIR/bin/storm nimbus"
# Find the sub-shell's Java process PID.
NIMBUS_PID_JAVA=`$JAVA_HOME/bin/jps -l |grep "backtype.storm.daemon.nimbus" |awk '{print $1}'`
# Check what the caller wants.
case "$1" in
start)
if [ "" = "$NIMBUS_PID_JAVA" ]; then
echo $CMD
# Storm processes look for a conf/ directory relative
# the processes start directory.
cd $HOME_DIR
# For compatibility with runit we cannot backgroud
# ourselves with a '&' at the end, though we do
# need to exec.
exec $CMD >$LOG_OUT 2>$LOG_ERR
else
echo "Service already running"
exit 1
fi
;;
stop)
if [ "" = "$NIMBUS_PID_JAVA" ]; then
echo "Service not running, nothing to stop"
exit 1
else
kill -9 $NIMBUS_PID_JAVA
exit 0
fi
;;
status)
# Status is found via actual running processes, rather than
# trusting a PID log file.
if [ "" = "$NIMBUS_PID_JAVA" ]; then
echo "Not running"
exit 1
elif [ "" != "$NIMBUS_PID_JAVA" ]; then
echo "Running"
exit 0
fi
;;
*)
echo "usage: daemon {start|stop|status}" >&2
exit 1
;;
esac