简体   繁体   中英

Heroku resque starting workers

I am using resque on Heroku and am unsure of how to start worker processes. From the tutorials I have read there are two systems promoted and i am unsure of which is best/correct and what the differences are.

The heroku tutorial uses the profile https://devcenter.heroku.com/articles/queuing-ruby-resque#resque-on-heroku

resque: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=7 bundle exec rake resque:work

The RedisToGo tutorial makes no use of a procfile for Heroku and instead makes use of a rake file /lib/tasks/resque.rb (I think this file should be called resque.rake) http://redistogo.com/documentation/resque

require 'resque/tasks'

task "resque:setup" => :environment do
  ENV['QUEUE'] = '*'
end

desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"

When I used the procfile system it created a third Heroku dyno (Web, Worker & Resque) whereas I understand the RedisToGo example above uses the Worker dyno for Resque.

Further to the point above if I am using resque for my background jobs is there any need for a worker dyno in Heroku or can I just have web & resque dynos?

Ok, for those that may follow with the same question or for myself in 12 months time when I have forgotten...

My research indicates the two methods above are mutually exclusive. Either start the worker using the profile method or start it using the latter. I could not get the procfile method to work however with the latter I was missing the required env variables to use the new signalling method. My solution was:

resque.rake

require 'resque/tasks'

task "resque:setup" => :environment do
  ENV['QUEUE'] = '*'
  ENV['TERM_CHILD'] = '1'
  ENV['RESQUE_TERM_TIMEOUT'] = '10'
end

desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM