Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Rake task to restart delayed_job_monitor if app not in maintenance mode
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.