Created
December 10, 2012 17:22
-
-
Save yulrizka/4251956 to your computer and use it in GitHub Desktop.
Storm init script. save as /etc/init.d/storm-nimbus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# /etc/init.d/storm-nimbus | |
# | |
# Startup script for storm-nimbus | |
# | |
# chkconfig: 2345 20 80 | |
# description: Starts and stops storm-nimbus | |
#. /etc/init.d/functions | |
stormBin=/home/user/storm/storm-0.8.1/bin/storm | |
stormSvc=$(echo $0 | cut -d'-' -f2) | |
desc="Storm $stormSvc daemon" | |
outFile="/var/log/storm/storm-$stormSvc.out" | |
stormUser=user | |
pidFile=/var/run/storm/storm-$stormSvc.pid | |
if ! [ -f $stormBin ]; then | |
echo "storm binary not found." | |
exit 5 | |
fi | |
if [ -f /etc/sysconfig/storm ]; then | |
. /etc/sysconfig/storm | |
fi | |
start() { | |
echo "Starting $desc (storm-$stormSvc): " | |
su $stormUser -c "nohup $stormBin $stormSvc >>$outFile 2>&1 &" | |
RETVAL=$? | |
return $RETVAL | |
} | |
stop() { | |
echo "Shutting down $desc (storm-$stormSvc): " | |
if [ $stormSvc == "ui" ]; then | |
pkill -f backtype.storm.ui.core | |
else | |
pkill -f backtype.storm.daemon.$stormSvc | |
fi | |
[ -e $pidFile ] && rm $pidFile | |
} | |
restart() { | |
stop | |
start | |
} | |
status() { | |
if [ $stormSvc == "ui" ]; then | |
pid=$(pgrep -f backtype.storm.ui.core) | |
else | |
pid=$(pgrep -f backtype.storm.daemon.$stormSvc) | |
fi | |
if [ -z $pid ]; then | |
echo "storm-$stormSvc is NOT running." | |
RETVAL=1 | |
else | |
echo "storm-$stormSvc is running (pid is $pid)." | |
RETVAL=0 | |
fi | |
} | |
case "$1" in | |
start) start;; | |
stop) stop;; | |
restart) restart;; | |
status) status;; | |
*) echo "Usage: $0 {start|stop|restart}" | |
RETVAL=2;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could also copy this file as
nimbus-supervisor
to make it init script for the superviors