Reputation: 12653
I have a Rails 3.2 app that uses the Queue_Classic gem, and is deployed on Heroku.
Currently my queued jobs are not being processed, unless I run heroku run rake qc:work
in the command line.
I have added a Procfile containing the following:
worker: bundle exec rake qc:work
but still no processing of the queue unless I run heroku run rake qc:work
manually.
What am I missing?
This app uses Unicorn, could this be having an impact?
Upvotes: 1
Views: 847
Reputation: 11395
Typically your workers run independently from your web processes. To run a worker, you need to set your process formation to run 1 worker:
$ heroku scale worker=1
Upvotes: 1
Reputation: 12653
After some digging around, I came up with the following solution.
I'm not sure if this is the best approach, or how it will behave as we scale web processes etc, but it's working for now.
I set up unicorn as usual, including
#Procfile
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
then i added the following config
#unicorn.rb
worker_processes 3
timeout 30
@qc_pid = nil
before_fork do |server, worker|
@qc_pid ||= spawn( "bundle exec rake qc:work" )
end
Upvotes: 0
Reputation: 3739
*Be sure to include queue_classic and queue_classic/tasks in your primary Rakefile.*
Upvotes: 0