Created
June 3, 2014 16:20
-
-
Save cserb/7a8b0ac743b57dcac760 to your computer and use it in GitHub Desktop.
queue_classic and capistrano
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
namespace :qc do | |
desc "start queue classic" | |
task :start do | |
run "nohup sh #{current_path}/qc_worker start > /dev/null 2>&1 &" | |
end | |
desc "stop queue classic" | |
task :stop do | |
run "sh #{current_path}/qc_worker stop" | |
end | |
end |
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 | |
app="/path/to/app" | |
pid_file="$app/shared/pids/qc.pid" | |
if [ "$1" == "start" ]; then | |
if [ ! -e "$pid_file" ]; then | |
cd $app/current && RAILS_ENV=production bundle exec rake qc:work & | |
touch $pid_file && echo "$!" > $pid_file | |
else | |
echo "Process seems to be running. Please make sure it is not and restart manually or delete the pid file and try again" | |
fi | |
fi | |
if [ "$1" == "stop" ]; then | |
if [ -e "$pid_file" ]; then | |
kill -s SIGKILL $(cat "$pid_file") | |
rm $pid_file | |
else | |
echo "No PID file found" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, why don't you wrap this up in Capistrano extension?