Created
October 12, 2012 21:44
-
-
Save abhishekkr/3881708 to your computer and use it in GitHub Desktop.
linux service script for resque-scheduler
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/sh | |
# | |
# chkconfig: - 85 15 | |
# description: resque-scheduler service script | |
# | |
app_name=$MY_APP_NAME | |
pidfile_sched="/var/run/$MY_APP_NAME-resque-sched.pid" | |
app_dir="/opt/$MY_APP_NAME" | |
. /etc/rc.d/init.d/functions | |
mykillproc() { | |
pid=`cat $1` | |
if [ -z $pid ] ; then | |
echo 'No Pid Found!' | |
return 127 | |
else | |
kill -9 $pid | |
rm -f $1 | |
echo "Pid:$pid killed" | |
fi | |
} | |
start() { | |
echo -n "Starting Resque Schedulers: " | |
cd $app_dir && BACKGROUND=yes PIDFILE=$pidfile_sched bundle exec rake resque:scheduler | |
retval=$? | |
echo | |
return $retval | |
} | |
stop() { | |
echo -n "Stopping Resque Schedulers: " | |
mykillproc $pidfile_sched | |
retval=$? | |
echo | |
return $retval | |
} | |
restart() { | |
stop | |
start | |
} | |
reload() { | |
restart | |
} | |
rh_status() { | |
status -p $pidfile_sched | |
} | |
rh_status_q() { | |
rh_status >/dev/null 2>&1 | |
} | |
case "$1" in | |
start) | |
rh_status_q && exit 0 | |
$1 | |
;; | |
stop) | |
rh_status_q || exit 0 | |
$1 | |
;; | |
restart) | |
$1 | |
;; | |
reload) | |
rh_status_q || exit 7 | |
$1 | |
;; | |
status) | |
rh_status | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|reload}" | |
exit 2 | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment