【问题标题】:How do I get a backtrace of hanging Ruby process?如何获得挂起 Ruby 进程的回溯?
【发布时间】:2019-01-30 23:33:13
【问题描述】:

有一个包含 Capybara、Selenium、Allure 的复杂测试套件,但都被滥用了:

  • 它会自行启动和退出 Chrome,而不是将这项工作留给 Capybara
  • 之前和之后的钩子放错了地方,造成的影响,例如,当你这样做时会填充远程数据库rspec --dry-run
  • Allure 报告 gem 几乎被遗弃了,我相信这里的集成也并非没有错误做法

现在当我运行测试时,它们有时会挂起,所以我按 ^C 但它们不会停止:

RSpec is shutting down and will print the summary report... Interrupt again to force quit.

无论我等待多长时间,甚至手动关闭浏览器,它都不会停止。

当我再次按^C 时,它什么也没有打印——没有回溯。
我怎么知道它挂在哪里?我如何随时获得它的回溯?

【问题讨论】:

标签: ruby interrupt backtrace


【解决方案1】:

输出Ruby相关进程。

终止 Rspec 进程。

$ ps aux | grep ruby

jun               3517   0.0  0.0  4443772   1240 s000  S+   12:07AM   0:00.21 /Users/jun/workspace/sf/app/vendor/bundle/ruby/2.6.0/gems/rb-fsevent-0.11.0/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/jun/workspace/sf/app/app/views
jun               3515   0.0  0.0  4434556   1360 s000  S+   12:07AM   0:00.22 /Users/jun/workspace/sf/app/vendor/bundle/ruby/2.6.0/gems/rb-fsevent-0.11.0/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/jun/workspace/sf/app/db /Users/jun/workspace/sf/app/app/controllers /Users/jun/workspace/sf/app/app/forms /Users/jun/workspace/sf/app/app/helpers /Users/jun/workspace/sf/app/app/jobs /Users/jun/workspace/sf/app/app/mailer /Users/jun/workspace/sf/app/app/mailers /Users/jun/workspace/sf/app/app/models /Users/jun/workspace/sf/app/app/policies /Users/jun/workspace/sf/app/app/validators
jun               3514   0.0  0.0  4419196   1272 s000  S+   12:07AM   0:00.20 /Users/jun/workspace/sf/app/vendor/bundle/ruby/2.6.0/gems/rb-fsevent-0.11.0/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/jun/workspace/sf/jdreamsr-app/spec/factories
jun               3513   0.0  0.0  4456060   1232 s000  S+   12:07AM   0:00.20 /Users/jun/workspace/sf/app/vendor/bundle/ruby/2.6.0/gems/rb-fsevent-0.11.0/bin/fsevent_watch --format=otnetstring --latency 0.1 /Users/jun/workspace/sf/app/config/locales
jun              17370   0.0  0.0  4259000    248 s006  R+    3:04AM   0:00.00 grep ruby
$ kill -9 3517
$ kill -9 3515
...

【讨论】:

  • 对不起,这无关紧要。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-13
  • 2011-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多