#!/bin/bash # # /etc/init.d/storm-<%= @storm_service %> # # Startup script for storm-<%= @storm_service %> # # description: Starts and stops storm-<%= @storm_service %> # stormBin=<%= @storm_install_dir %>/bin/storm stormSvc=<%= @storm_service %> desc="Storm $stormSvc daemon" outFile="/var/log/storm/storm-$stormSvc.out" if ! [ -f $stormBin ]; then echo "storm binary not found." exit 5 fi start() { echo "Starting $desc (storm-$stormSvc): " su <%= @storm_user %> -c "nohup $stormBin <%= @storm_service %> >>$outFile 2>&1 &" RETVAL=$? sleep 2 return $RETVAL } stop() { echo "Shutting down $desc (storm-$stormSvc): " if [ $stormSvc == "ui" ]; then procname="storm.ui.core" else procname="storm.daemon.$stormSvc" fi pkill -f $procname } restart() { stop start } status() { if [ $stormSvc == "ui" ]; then pid=$(pgrep -f storm.ui.core) else pid=$(pgrep -f storm.daemon.$stormSvc) fi if [ -z $pid ]; then echo "storm-$stormSvc is NOT running." exit 1 fi echo "storm-$stormSvc running with pid $pid" exit 0 } case "$1" in start) start;; stop) stop;; restart) restart;; status) status;; *) echo "Usage: $0 {start|stop|restart}" RETVAL=2;; esac exit $RETVAL