Last active
January 3, 2017 03:42
-
-
Save adamrunner/cc9b9df4befff9bf53a9 to your computer and use it in GitHub Desktop.
resque-scheduler
This file contains hidden or 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 | |
### BEGIN INIT INFO | |
# Provides: resque_scheduler | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Starts Scheduler for Resque | |
# Description: This script will start the resque scheduler task so | |
# jobs will be automatically scheduled. | |
# | |
### END INIT INFO | |
# Author: Adam Runner <[email protected]> | |
# | |
export RAILS_ENV=production | |
USER_ID=`id -u` | |
APP_DIR="APP_DIR_GOES_HERE" | |
LOG_DIR="LOG_DIR_GOES_HERE" | |
PID_DIR="PID_DIR_GOES_HERE" | |
REDIS_PID=`cat /var/run/redis_6379.pid` | |
SCHEDULER_PID_FILE="$PID_DIR/resque_scheduler.pid" | |
if [ -e $SCHEDULER_PID_FILE ]; then | |
SCHEDULER_PID=`cat $SCHEDULER_PID_FILE` | |
fi | |
if [ -z $REDIS_PID ]; then | |
service redis-server start | |
fi | |
case "$1" in | |
start) | |
cd $APP_DIR | |
su harbinger -c "PIDFILE=$PID_DIR/resque_scheduler.pid RAILS_ENV=production nohup rake resque:scheduler >> $LOG_DIR/resque_scheduler.log 2>&1 &" | |
;; | |
stop) | |
if [ $SCHEDULER_PID ]; then | |
kill -QUIT $SCHEDULER_PID | |
rm $SCHEDULER_PID_FILE | |
fi | |
;; | |
restart) | |
service resque-scheduler stop | |
service resque-scheduler start | |
;; | |
*) | |
echo "Usage: service resque-scheduler {start|stop|restart}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment