Skip to content

Instantly share code, notes, and snippets.

@hvanhonacker
Forked from cserb/deploy.rb
Last active August 29, 2015 14:17
Show Gist options
  • Save hvanhonacker/6a40310c479c90467f29 to your computer and use it in GitHub Desktop.
Save hvanhonacker/6a40310c479c90467f29 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment