Created
May 15, 2012 12:18
-
-
Save mattsoutherden/2701324 to your computer and use it in GitHub Desktop.
Wait for delayed job to stop
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
# Run DelayedJob | |
namespace :delayed_job do | |
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 | |
desc "Restart the delayed_job process" | |
task :restart, :roles => :app do | |
stop | |
wait_for_process_to_end('delayed_job') | |
start | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment