Created
September 7, 2010 10:30
-
-
Save MBO/568143 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
namespace :delayed_job do | |
desc "*HACK* Restart the delayed_job process" | |
task :restart do | |
stop | |
enforce_stop_delayed_job | |
start | |
end | |
# Send SIGTERM to delayed_job associated with current logfile and then | |
# wait for every delayed_job to finish | |
def enforce_stop_delayed_job | |
run %Q{ | |
lsof '#{current_path}/log/delayed_job.log' | awk '/^ruby/ { system("kill " $2) }' ; | |
COUNT=1; | |
until [ $COUNT -eq 0 ]; do | |
COUNT=`lsof '#{current_path}/log/delayed_job.log' | grep '^ruby' |wc -l` ; | |
echo 'waiting for delayed_job to end' ; | |
sleep 2 ; | |
done | |
}.split("\n").join('') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment