I have installed resque correctly, but to process all queues I need to run
rake resque:work QUEUE='*'
The problem is that I need to keep the terminal window opened, otherwise resque:work won't works.
Do you know a way to auto-run that rake command every time I run "rails server" ?
I'm on Localhost
lib/tasks/resque.rake
require 'resque/tasks'
task "resque:setup" => :environment do
ENV['QUEUE'] = "*"
end
Then restart your Rails server. Open up http://localhost:3000/resque in a browser to check out the web running jobs and schedules. If you are using Resque-scheduler then it will add more options for you in the resque-web UI. Those options allows you to view queues and manually start queuing.
Resque (pronounced like "rescue") is a Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later.
Instead of calling the invoke function, you can use a gem like foreman that can invoke all the other tasks. This is useful if you are looking to have a largely platform neutral solution and also while deploying into cloud. Your Procfile can have the following contents:
web: bundle exec thin start -p $PORT
worker: bundle exec rake resque:work QUEUE=*
clock: bundle exec rake resque:scheduler
Source:introduction to foreman.
Now to start the server, you just have to issue foreman start command which forks off child threads to perform individual work.
Edit: Answer from 2012! Seems that this works just for Rails 2!
Add an initializer in config/initializers with something like this:
Rake::Task["resque:work QUEUE='*'"].invoke
Not tested!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With