Does maintenance mode turn off scheduler? If not does a way exist to temporarily disable scheduler without manually deleting every item?
If you need to temporarily disable access to your Heroku app (for example, to perform a large migration), you can enable Heroku's built-in maintenance mode. While in maintenance mode, your app serves a static maintenance page to all visitors.
Scheduler is a free add-on for running jobs on your app at scheduled time intervals, much like cron in a traditional server environment. While Scheduler is a free add-on, it executes scheduled jobs via one-off dynos that will count towards your monthly usage. Scheduler job execution is expected but not guaranteed.
Reliable delivery Heroku Scheduler is a free add-on, but it doesn't guarantee that jobs will be executed at their scheduled time, or at all for that matter. While it is rare, the possibility that a job may be skipped or run twice does exist.
I recently ran into the issue of not being able to pause or disable the Heroku scheduler as well. I needed to do a DB upgrade so I couldn't use the delayed job suggestion. Not finding a better solution I wrote a little disable rake task.
task :pause_scheduler => :environment do
if ENV['PAUSE_SCHEDULER'] == 'true'
puts 'Scheduler Paused'
exit
end
end
Then I just inherit from :pause_scheduler
instead of from :environment
for all of my Heroku scheduler cron jobs and set the PAUSE_SCHEDULER environment variable to 'true' when I want to turn it off.
heroku config:set PAUSE_SCHEDULER=true
Seems to work pretty well. Much better than deleting and recreating all my scheduled jobs at any rate.
Just remember to turn it back on after you're done.
heroku config:set PAUSE_SCHEDULER=false
Hope that helps!
Nope. The only thing maintenance mode does is tell the router to refuse to forward new web requests. Everything else still runs, including one-off dynos (which the scheduler uses): https://devcenter.heroku.com/articles/maintenance-mode
One way to work around this would be to have your scheduled tasks just enqueue a job in a delayed job processing system (like delayed_job or resque). That way, you can scale the worker dynos down to 0 and nothing serious should happen during downtime, instead of the database or external services accidentally being written to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With