如何使用Byebug进行远程处理(例如,pow)
如何连接到Byebug的远程调试实例(与Pow等一起使用)?
约瑟夫的回答很好,但在某些方面令人困惑。 他将byebug服务器的起始位置放在config/environments/development.rb
,当它在初始化程序中更好时。 此外,环境变量的导出位于.powenv
或.powrc
。 这就是我开始工作的方式。
在你的gemfile中:
gem 'byebug'
在命令行上:
bundle install
如果您使用Pow,请将以下内容添加到.powenv
:
export BYEBUGPORT=3001
如果您正在使用其他框架(例如,只是foreman
),您可能需要修改.env
。
在config/initializers/byebug.rb
if Rails.env.development? and ENV['BYEBUGPORT'] require 'byebug/core' Byebug.start_server 'localhost', ENV['BYEBUGPORT'].to_i end
最后在命令行上:
touch tmp/restart.txt
一旦你去你的pow站点,应该启动byebug服务器。 在命令行上,您现在可以执行以下操作:
[bundle exec] byebug -R localhost:3001
我不得不将来自几个不同来源的信息拼凑起来完成上述工作,所以为了方便起见,我想我会在这里加入一份综合指南:
- https://github.com/deivid-rodriguez/byebug/pull/29 ,
- https://github.com/deivid-rodriguez/byebug/pull/36 ,
- https://github.com/deivid-rodriguez/byebug/issues/31
- http://mines.mouldwarp.com/2012/04/pow-guard-and-rdebug-staying-in-web-app.html
以下是步骤:
-
在config / environments / development.rb中,添加:
require 'byebug' #set in your .powconfig if ENV['RUBY_DEBUG_PORT'] Byebug.start_server 'localhost', ENV['RUBY_DEBUG_PORT'].to_i else Byebug.start_server 'localhost' end
-
重启Pow并访问yourapp.dev
-
运行以下命令:
[bundle exec] byebug -R localhost:
您应该看到与远程实例的成功连接。