puma / puma-dev

A tool to manage rack apps in development with puma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ruby debugger?

joelmoss opened this issue · comments

It would be awesome of puma-dev worked with the Ruby debug gem, but I've not been able to get it working.

Is this possible? Has anyone managed to integrate the two at all?

What have you tried? Looks like there have been many issues solved in the debug gem but not released yet, so you might wanna try using the latest code from the GitHub repo.

See also this comment ruby/debug#287 (comment)

Well as puma runs in the background, I need to attach (open) the debugger to Puma. So I tried rdbg --open and placed the debugger call in a Rails controller action. After loading the page, it returns a 502. The puma-dev log shows:

platform-2ef368ef[3675]: Puma starting in single mode...
platform-2ef368ef[3675]: * Puma version: 5.6.2 (ruby 3.1.0-p0) ("Birdie's Version")
platform-2ef368ef[3675]: *  Min threads: 0
platform-2ef368ef[3675]: *  Max threads: 5
platform-2ef368ef[3675]: *  Environment: development
platform-2ef368ef[3675]: *          PID: 3675
platform-2ef368ef[3675]: /Users/joelmoss/dev/clients/harleytherapy/platform/config/initializers/sidekiq.rb:2: warning: Sidekiq's Delayed Extensions will be removed in Sidekiq 7.0
platform-2ef368ef[3675]: * Listening on unix:/Users/joelmoss/.puma-dev/harleytherapy/tmp/puma-dev-9188.sock
platform-2ef368ef[3675]: Use Ctrl-C to stop
! App 'platform-2ef368ef' booted
platform-2ef368ef[3675]: [2, 11] in ~/dev/clients/harleytherapy/platform/app/controllers/account/therapist_controller.rb
platform-2ef368ef[3675]:      2|   include Account::Therapist::CommonConcerns
platform-2ef368ef[3675]:      3| 
platform-2ef368ef[3675]:      4|   skip_before_action :authenticate_therapist!, :ensure_complete_profile!, only: :become
platform-2ef368ef[3675]:      5| 
platform-2ef368ef[3675]:      6|   def index
platform-2ef368ef[3675]: =>   7|     debugger
platform-2ef368ef[3675]:      8|     return unless current_therapist.approved?
platform-2ef368ef[3675]:      9| 
platform-2ef368ef[3675]:     10|     @hide_breadcrumbs = true
platform-2ef368ef[3675]:     11|     @next_appointment = current_therapist.appointments.next.take
platform-2ef368ef[3675]: =>#0   Account::TherapistController#index at ~/dev/clients/harleytherapy/platform/app/controllers/account/therapist_controller.rb:7
platform-2ef368ef[3675]:   #1   ActionController::BasicImplicitRender#send_action(method="index", args=[]) at ~/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-7.0.2.2/lib/action_controller/metal/basic_implicit_render.rb:6
platform-2ef368ef[3675]:   # and 100 frames (use `bt' command for all frames)
2022/03/09 17:11:26 http: proxy error: EOF
platform-2ef368ef[3675]: (rdbg) Really quit? [Y/n] ! Killing 'platform-2ef368ef' (3675) - 'stdout/stderr closed'
* App 'platform-2ef368ef' shutdown and cleaned up

Running rdbg -A returns No debug session is available..

Sorry for my ignorance, but I'm sure I'm missing something, so any help would be appreciated.

ok, so I was missing the require 'debug/open_nonstop'. Once I add that, I can attach with rdbg -A!

Sorry for wasting your time, and thx

One annoyance that I keep coming across when I start rdbg, is that is always pauses on puma/single.rb:61 on startup. I'm assuming this has something to do with the rescue being used there? Is there a way to ignore that?

❯ rdbg -A
# No sourcefile available for /Users/joelmoss/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puma-5.6.2/lib/puma/single.rb
=>#0    [C] Thread#join at ~/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puma-5.6.2/lib/puma/single.rb:61
  #1    Puma::Single#run at ~/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puma-5.6.2/lib/puma/single.rb:61
  # and 20 frames (use `bt' command for all frames)

Stop by SIGURG

I think this may be a question better posted to puma/puma rather than puma-dev?