13

I've tried pry and remote-pry, but no luck. I'm familiar with logging, but I want to be able to step thru my code and look at variables.

Does anyone know of anything I can use to debug Sidekiq?

ToddT
  • 3,084
  • 4
  • 39
  • 83

3 Answers3

20

Workers are designed to be trivial to run. Put pry in your worker code and run it in the rails console.

> MyWorker.new.perform(some_args)
Mike Perham
  • 21,300
  • 6
  • 59
  • 61
  • 6
    I have an instance where the timing of an async job is an issue and running it in the console does not give me the necessary environment to debug. – Abram Mar 07 '17 at 06:00
14

The best thing I've come up with is this gem gem 'pry-remote' it works great and stops all processes from running. And it works like pry just put in binding.remote_pry and you've got a stopping point.

ToddT
  • 3,084
  • 4
  • 39
  • 83
0

You can use byebug but you have to require it inside the class definition of the job. For instance,

class SomeJob < ActiveJob::Base
  require 'byebug'
  
  def perform(*args)
    byebug
  end
end

then in your rails console run

SomeJob.perform_now(*args)

This will cause a breakpoint to appear where ever you have byebug called with your typical byebug prompt inside your rails console.

Paa Yaw
  • 431
  • 6
  • 8