Created
January 17, 2012 13:24
-
-
Save afriqs/1626611 to your computer and use it in GitHub Desktop.
Rake task to restart delayed_job_monitor if app not in maintenance mode
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
# Workers are watched by built-in delayed_job_monitor | |
# Use [bundle exec] rake jobs:restart to restart delayed_job_monitor | |
# * if app in maintenance mode (cf. maintenance.html), will do nothing | |
# * else if delayed_job_monitor yet running, will do nothing | |
# * else will restart delayed_job_monitor | |
# Can be used via a cron, for example : | |
# 15 * * * * RAILS_ENV=testing bundle exec rake jobs:restart | |
namespace :jobs do | |
desc "Restart delayed_job_monitor if no worker yet running" | |
task :restart do | |
maintenance_file = Rails.root + 'public/system/maintenance.html' | |
unless maintenance_file.exist? | |
cmd = "#{Rails.root}/script/delayed_job" | |
args = ["start", "-m"] | |
exec cmd, *args | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment