Using Resque, Puma and Scheduler together on Heroku

不问归期 提交于 2019-12-04 04:58:05

问题


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:

...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.


回答1:


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.



来源:https://stackoverflow.com/questions/41537142/using-resque-puma-and-scheduler-together-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!