ruby-on-railsrubydelayed-job

How can I debug code running in a delayed_job task in the IRB console?


I have a background task that runs using delayed_job.

I can see that it does run from the logging statements. It does not seem to have the correct result, compared to running it in the foreground, so I want to debug it in the IRB console.

I am running the background task with

rake jobs:work

and it does not trigger the debugger statement.

How can I load the debugger?


Solution

  • Start a standard rails console

    ruby script/console
    

    And start a worker inside here, this will see and trigger the debugger statement.

    worker = Delayed::Worker.new
    worker.start