简体   繁体   中英

How can I debug my Rack app while it's running?

I wrote a rack app ( here ) which locks up about once or twice per day, and I need to debug the app.

So, I tried following this: http://robots.thoughtbot.com/using-gdb-to-inspect-a-running-ruby-process . I tried debugging against a simple test script:

class MyTest
  def initialize
    @a ||= 1
  end

  def something
    @a += 1
    puts @a
  end
end

test = MyTest.new

while true do
  sleep 3
  test.something
end

However, I get this:

(gdb) redirect_stdout
No symbol "rb_eval_string" in current context.
(gdb) ruby_eval('Kernel.caller')
No symbol "rb_p" in current context.

Any idea what I need to do different? Or is there an alternative way to debug? I want to avoid using "puts" statements and writing to logs, as I've tried that already, and it's very hit or miss.

Looks like it was not attaching to the process properly. Running in root mode let me attach and debug. I ran call rb_backtrace() , and that gave some useful output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM