Search code examples
herokurakebackgroundworkerredisresque

Running rake tasks to start Resque workers on Heroku


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?


Solution

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