Resque scheduler on heroku without extra workers

require 'resque/tasks'
require 'resque_scheduler/tasks'
# Scheduler needs very little cpu, just start it with a worker.
desc "schedule and work, so we only need 1 dyno"
task :schedule_and_work do
  if Process.fork
    sh "rake environment resque:work"
    sh "rake resque:scheduler"

15 thoughts on “Resque scheduler on heroku without extra workers

  1. It starts multiple, not sure if that is safe (does it schedule a job multiple times ?), also maybe schedulers die if there already is a scheduler running,
    so you could make this more complicated by cheching if a scheduler is running or not, or check/make sure the multiple schedulers are safe to run

      • So this “worker: bundle exec rake resque:work COUNT=1 QUEUE=*” would change to “worker: bundle exe rake schedule_and_work COUNT=1 QUEUE=*” ?

        Would you be willing to add this to stack overflow too, I want to make sure you get credit for this? Also, I assume I delete the scheduler reference in the procfile correct?

      • Thank you for your help btw, I am trying to find 2 options. One now, and one for growth so I want to make sure I have the setup in place.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s