Skip to content

Instantly share code, notes, and snippets.

@cserb
Created June 3, 2014 16:20
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cserb/7a8b0ac743b57dcac760 to your computer and use it in GitHub Desktop.
Save cserb/7a8b0ac743b57dcac760 to your computer and use it in GitHub Desktop.
queue_classic and capistrano
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
#!/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
@toydestroyer
Copy link

Hey, why don't you wrap this up in Capistrano extension?

@cserb
Copy link
Author

cserb commented Feb 20, 2016

@toydestroyer: I'm not using this atm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment