Created
August 31, 2009 10:58
-
-
Save chrisfinne/178397 to your computer and use it in GitHub Desktop.
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
after "deploy:stop", "delayed_job:stop" | |
after "deploy:start", "delayed_job:start" | |
after "deploy:restart", "delayed_job:restart" | |
namespace :delayed_job do | |
desc "Stop the delayed_job process" | |
task :stop, :roles => :app do | |
run "cd #{current_path}; script/delayed_job -e #{rails_env} stop" | |
end | |
desc "Start the delayed_job process" | |
task :start, :roles => :app do | |
run "cd #{current_path}; script/delayed_job -e #{rails_env} start -n 3" | |
end | |
desc "Restart the delayed_job process" | |
task :restart, :roles => :app do | |
stop | |
wait_for_process_to_end('delayed_job') | |
start | |
end | |
end | |
def wait_for_process_to_end(process_name) | |
run "COUNT=1; until [ $COUNT -eq 0 ]; do COUNT=`ps -ef | grep -v 'ps -ef' | grep -v 'grep' | grep -i '#{process_name}'|wc -l` ; echo 'waiting for #{process_name} to end' ; sleep 2 ; done" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2.0.3 of delayed_job (possibly earlier, not sure), dropped support for the '-e' switch, so now you would want:
run "cd #{current_path}; #{rails_env} script/delayed_job stop"
See:
http://github.com/collectiveidea/delayed_job/issues/issue/7