c2h2
c2h2

Reputation: 12359

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?

Upvotes: 6

Views: 3435

Answers (3)

David Morales
David Morales

Reputation: 18064

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

Delayed::Worker.sleep_delay = 2

Upvotes: 14

Brian Armstrong
Brian Armstrong

Reputation: 19863

Try setting

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

in your config/initializers/delayed_job_config.rb file.

Upvotes: 1

drhyde
drhyde

Reputation: 1921

Sure, just go to RAILS_ROOT/vendor/plugins/delayed_job/lib/delayed/worker.rb, look for the line

self.sleep_delay = 5

and change it to

self.sleep_delay = 2

or whatever you'd like

On an earlier version of DJ I set this to as little as 0.1 so that the jobs in the queue get picked up for processing almost instantly and it works just fine.

Upvotes: 0

Related Questions