Created
June 13, 2013 15:49
-
-
Save AvnerCohen/5774806 to your computer and use it in GitHub Desktop.
Control Resque via BASH / Shell / Command line, the various rake tasks out there does not seem to do the job clean enough
run as, added code to specifically take advantage of the already present resque.yml configuration file: ./resque_control.sh start
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 | |
echo "Executing Resque Manager." | |
start() { | |
echo -n "Starting resque..." | |
RAILS_ENV="$TARGET_ENV" QUEUE="v2_processing" VERBOSE="1" nohup bundle exec rake environment resque:work --trace > ./log/resque.log & | |
return | |
} | |
stop() { | |
echo -n "Shutting down resque... " | |
RUBY_SCRIPT="resque_config=YAML.load_file('./config/resque.yml'); puts \"#{resque_config['$TARGET_ENV']['host']}:#{resque_config['$TARGET_ENV']['port']}\"" | |
REDIS_CON=`ruby -ryaml -e "$RUBY_SCRIPT"` | |
bundle exec resque list -r "$REDIS_CON" | grep `hostname`| awk -F : '{ print $2 }' | xargs kill -QUIT | |
return | |
} | |
TARGET_ENV=${2:-production} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart} <ENV>" | |
exit 1 | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment