3

After reviewing numerous guides I would like to confirm my setup. Right now my procfile looks like:

web: bundle exec puma -C config/puma.rb config.ru
resque: TERM_CHILD=1 RESQUE_TERM_TIMEOUT=10 QUEUES=* bundle exec rake resque:work
worker: bundle exec rake resque:work COUNT=1 QUEUE=*
scheduler: bundle exec rake resque:scheduler

...and in Heroku:

enter image description here

...and my rake resque setup task:

require 'resque'
require 'resque/tasks'
require 'resque/scheduler/tasks'

# http://jademind.com/blog/posts/enable-immediate-log-messages-of-resque-workers/
namespace :resque do
  desc 'Initialize Resque environment'
  task setup: :environment do
    ENV['QUEUE'] ||= '*'
    Resque.logger.level = Logger::INFO
  end

  task scheduler_setup: :environment
end

desc 'Alias for resque:work'
task 'jobs:work' => 'resque:work'

So here are my questions:

  1. Do I need both a Resque and a worker configuration in my procfile?
  2. Do I need to have a separate dyno for the scheduler and the worker? This means 3 total dynos?

Update

I came across this posting which I am giving a try https://grosser.it/2012/04/14/resque-scheduler-on-heroku-without-extra-workers/. The goal is to be able to optionally use the 2 free dynos for my web and workers and scheduler. Once the application grows I want to break them out into their own dynos.

halfer
  • 19,824
  • 17
  • 99
  • 186
Chris Hough
  • 3,389
  • 3
  • 41
  • 80

2 Answers2

0

From the blog post I found

He mentioned to role with this now...

web: bundle exec puma -C config/puma.rb config.ru
worker: bundle exe rake schedule_and_work COUNT=1 QUEUE=* TERM_CHILD=1 RESQUE_TERM_TIMEOUT=10

..and upgrade to this once we need more dynos...

web: bundle exec puma -C config/puma.rb config.ru
resque: TERM_CHILD=1 RESQUE_TERM_TIMEOUT=10 QUEUES=* bundle exec rake resque:work
worker: bundle exec rake resque:work
scheduler: bundle exec rake resque:scheduler

This will allow us to use a web dyno until we want to pay for full time scheduler dynos.

Chris Hough
  • 3,389
  • 3
  • 41
  • 80
  • awesome @grosser, if you want to leave an answer I can mark yours b/c it was covered on your blog. that way you will get credit and I will delete this one. thank you so much for your help. – Chris Hough Jan 09 '17 at 02:01
  • Well why do you need two `rake resque:work`? And can you copy the solution from the blog in case it goes bye-bye? – Chloe Aug 10 '18 at 03:08
  • @Chloe post answer added – Chrismisballs Sep 19 '22 at 17:38
0
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"
  else
    sh "rake resque:scheduler"
    Process.wait
  end
end

From the blog post mentioned in update

Chrismisballs
  • 167
  • 12