Skip to content

Instantly share code, notes, and snippets.

@spiceee
Created March 13, 2010 20:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spiceee/331532 to your computer and use it in GitHub Desktop.
Save spiceee/331532 to your computer and use it in GitHub Desktop.
namespace :delayed_job do
desc "Start delayed_job process"
task :start, :roles => :app do
run "cd #{current_path}; RAILS_ENV=production script/delayed_job start"
end
desc "Stop delayed_job process"
task :stop, :roles => :app do
run "cd #{current_path}; RAILS_ENV=production script/delayed_job stop"
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