How to run "rake resque: work QUEUE = *" when loading the Rails server?

I installed resque correctly, but to process all the queues I need to run

rake resque:work QUEUE='*' 

The problem is that I need the terminal window to open, otherwise resque: the operation will not work.

Do you know a way to automatically run this rake command every time I start the rails server?

I am Localhost

Lib / tasks / resque.rake

 require 'resque/tasks' task "resque:setup" => :environment do ENV['QUEUE'] = "*" end 
+7
source share
3 answers

Instead of calling the invoke function, you can use a gem like foreman , which can call all other tasks. This is useful if you want an almost neutral solution for the platform, as well as when deploying in the cloud. Your Procfile may 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 the wizard .

Now, to start the server, you just need to issue the wizard start command, which discards the child threads to do a separate job.

+9
source

Edit: answer from 2012! This seems to work only for Rails 2!

Add an initializer in config / initializers with something like this:

 Rake::Task["resque:work QUEUE='*'"].invoke 

Not tested!

+2
source

The best way to do this is

 ENV['QUEUE'] = "*" Rake::Task["resque:work"].invoke 
0
source

All Articles