[Rails] Run Queued Tasks Using 'delayed_job', Now With Intervals!

on
| 1 min read

If you don’t already know, ’delayed_job’ is a database based asynchronously priority queue system extracted from Shopify.

I was seeking for a lightweight, easy to use solution for queueing tasks, ‘delayedjob’ fits the bill _almost perfectly. ;)

One thing we needed to do for a Rails 2 project at Envato, was to queue the tasks and to run them one after another, at a set interval. ‘delayed_job’ unfortunately doesn’t come with this feature.

So, instead of searching for more complicated solutions or reinventing the wheels, Imade a couple of commits to my fork to add this functionality as well as to fix some rails 3 compatibility issues.

Now you can simply add the following line to your config/initializers/delayed_job_config.rb file to have the tasks run at 1 minute interval.

Delayed::Worker.run_interval = 60

A pull request has been issued, hopefully it’ll come as a standard feature soon. :)

Enjoy what you are reading? Sign up for a better experience on Persumi.

Comments