Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Maintenance Mode Disable Scheduler on Heroku

Tags:

heroku

Does maintenance mode turn off scheduler? If not does a way exist to temporarily disable scheduler without manually deleting every item?

like image 719
Kevin Sylvestre Avatar asked Dec 08 '13 03:12

Kevin Sylvestre


People also ask

What is maintenance mode in heroku?

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.

How does heroku scheduler work?

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.

Is heroku scheduler reliable?

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.


2 Answers

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!

like image 141
user2726983 Avatar answered Oct 10 '22 18:10

user2726983


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.

like image 32
Ari Avatar answered Oct 10 '22 16:10

Ari