Last Updated: February 25, 2016
·
8.414K
· kennym

Debugging delayed_job jobs from within the console

Did you ever wanted to step in with the Ruby debugger to fix or inspect a background job? Here's how:

DISCLAIMER: Tested with delayed_job 2.14. Should work with recent versions, too.

Open a rails console within your project

$ rails c
Loading development environment (Rails 3.2.13)

Initialise a delayed_job worker, and make it output to console by passing {quiet: false} to its initialiser.

1.9.2p325 :001 > worker = Delayed::Worker.new({quiet: false})
 => #<Delayed::Worker:0x007fa295ecef48 @quiet=false>

Start the worker

1.9.2p325 :002 > worker.start

Now you can put a debugger statement into your jobs and debug nicely without using loggers.

Reference:
http://blog.kennymeyer.net/programming/2013/07/11/debugging-delayed-job-from-console/

3 Responses
Add your response

Thank you, this turned out to be very useful for me. Worked on OSX Mavericks
* delayedjob (4.0.0)
* delayed
jobactiverecord (4.0.0)
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
Rails 4.0.2

over 1 year ago ·

Awesome! Very useful tip.

over 1 year ago ·

Nope, its not working for me.

over 1 year ago ·