简体   繁体   English

如何在Rack应用程序运行时调试它?

[英]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 . 所以,我试着这样做: 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. 我想避免使用“puts”语句并写入日志,因为我已经尝试过了,而且非常受欢迎。

Looks like it was not attaching to the process properly. 看起来它没有正确附加到过程。 Running in root mode let me attach and debug. 在root模式下运行让我附加和调试。 I ran call rb_backtrace() , and that gave some useful output. 我运行了call rb_backtrace() ,这给了一些有用的输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何确保Ruby使用Rails应用程序中提供的Rack gem? - How can I ensure Ruby is using the Rack gem that's vendored in my Rails app? 如何从sinatra应用程序中的类将数据传递到websocket机架? - How can I pass data to websocket-rack from a class in my sinatra app? 如何使机架式应用程序变成宝石? - How do I make my rack app a gem? 如何调试Omniauth和Rack应用程序? - How do I debug Omniauth and Rack applications? 如何将通过机架上传的文件直接传送到S3? - How can I pipe a rack file upload directly to S3? 那么,如何从我的机架应用程序中删除 Rack::ShowExceptions 呢? - So, how to remove Rack::ShowExceptions from inside my rack app? 在机架应用程序中,如何确定正在运行的Web服务器? - Within a rack application, how can I tell which web server is running? 如何在服务器运行时添加/删除机架中间件? - How to add/remove rack middleware while server is running? 如何获得正在通过机架测试测试的Sinatra应用程序实例? - How do I get the Sinatra app instance that's being tested by rack-test? 如果我在我的机器上运行不同版本的 Ruby,如何测试从 GitHub 克隆的某人的 Rails 应用程序? - How can I test someone's Rails app cloned from GitHub if I am running a different version of Ruby on my machine?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM