Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you alter the polling time interval (5 seconds) for delayed_job worker?

Delayed job is great, but I would like to change its timer interval to be more frequent (every 2 second) to meet my special need.

Is there a config or hard-coding anywhere to change it?

like image 500
c2h2 Avatar asked Mar 18 '11 11:03

c2h2


People also ask

How do you restart a delayed job?

Restart Delayed Job on deploy You must remove that one now if you have it. It basically does the same thing that we will add now but without using upstart. We will now create a new file that will host our start, stop and restart tasks. Create a file at lib/capistrano/tasks/delayed_job.

What is a Delayed job?

Delayed Job, also known as DJ, makes it easy to add background tasks to your Rails applications on Heroku. You can also use Resque and many other popular background queueing libraries. Delayed Job uses your database as a queue to process background jobs.

How do I know if my job is running late?

The most simple way to check whether delayed_job is running or not, is to check at locked_by field. This field will contain the worker or process locking/processing the job. Running Delayed::Job. where('locked_by is not null') will give you some results, if there are jobs running.


2 Answers

With DJ 3.0 you can add this to the config/initializers/delayed_job_config.rb file:

Delayed::Worker.sleep_delay = 2
like image 186
David Morales Avatar answered Oct 19 '22 23:10

David Morales


Try setting

Delayed::Worker.const_set("SLEEP", 2)

in your config/initializers/delayed_job_config.rb file.

like image 38
Brian Armstrong Avatar answered Oct 20 '22 00:10

Brian Armstrong