Justin Meltzer
Justin Meltzer

Reputation: 13548

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?

Upvotes: 4

Views: 3960

Answers (2)

Alexey Zakharov
Alexey Zakharov

Reputation: 25102

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.

Upvotes: 3

Sam 山
Sam 山

Reputation: 42865

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.

Upvotes: -1

Related Questions