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/
Written by Kenny Meyer
Related protips
3 Responses
Thank you, this turned out to be very useful for me. Worked on OSX Mavericks
* delayedjob (4.0.0)
* delayedjobactiverecord (4.0.0)
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]
Rails 4.0.2
Awesome! Very useful tip.
Nope, its not working for me.