开发者

Running rake tasks to start Resque workers on Heroku

开发者 https://www.devze.com 2023-03-28 03:12 出处:网络
So I have Resque and redis to go set up on Heroku and this is what my resque.rake file looks like: require \'resque/tasks\'

So I have Resque and redis to go set up on Heroku and this is what my resque.rake file looks like:

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"

I ran heroku rake jobs:work and got one worker running. This worked perfectly. My background jobs were being completed.

Then I made some changes in my code, pushed to heroku, and still saw that I had one worker running. However, while jobs were being added to the queue, the worker was not receiving any jobs. So I ran heroku rake jobs:work again, it said I had two workers running, and my jobs were being completed.

My question is why did this happen? Do I need to run this rake task every time I push to heroku开发者_运维百科? Is there a way to automate this? Also, although I have two workers running, there seems to be only one that is working. Is there a way to get back to one worker?


You should use Procfile for resque jobs on heroku http://devcenter.heroku.com/articles/procfile

Keep in mind that Procfile is used on new Heroku Cedar Stack.


You only need one worker for Resque. You will need to run heroku rake jobs:work or use Resque-Scheduler (cron, or something to run that task) to to automatically run your jobs.

0

精彩评论

暂无评论...
验证码 换一张
取 消