撬开生产服务器——我怎样才能让它在那里工作?
Pry on the production server - how can I make it work there?
我可以使用 binding.pry
在本地调试应用程序。但我也需要在远程服务器 (webiste) 上这样做,因为在本地我没有任何错误,但在生产中我有。所以将 binding.pry
放在服务器的源文件中,当我向网站发出 post 请求时,我没有 return 任何响应,甚至当我 运行 rails console
在服务器上没有任何改变并且 rails console
.
中没有输出
它是一个开发服务器,所以它在互联网上可见,但它是一个开发服务器,尽管对于 rails 它是生产服务器,因为 RAIL_ENV
等于 production
。我真的需要使用 pry 在本地进行调试。我该怎么做?
更新:
# bundle exec pry-remote
/usr/lib/ruby/1.9.1/drb/drb.rb:736:in `rescue in block in open': druby://127.0.0.1:9876 - #<Errno::ECONNREFUSED: Connection refused - connect(2)> (DRb::DRbConnError)
from /usr/lib/ruby/1.9.1/drb/drb.rb:730:in `block in open'
from /usr/lib/ruby/1.9.1/drb/drb.rb:729:in `each'
from /usr/lib/ruby/1.9.1/drb/drb.rb:729:in `open'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1191:in `initialize'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1171:in `new'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1171:in `open'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1105:in `with_friend'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1086:in `method_missing'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/gems/pry-remote-0.1.8/lib/pry-remote.rb:289:in `run'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/gems/pry-remote-0.1.8/bin/pry-remote:4:in `<top (required)>'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/bin/pry-remote:19:in `load'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/bin/pry-remote:19:in `<main>'
我假设您的生产应用程序 运行 由某种守护程序应用程序服务器(例如 Puma 或 Unicorn)提供。
在此设置中,pry-remote 可以提供帮助。
- 将其添加到您的 Gemfile
- 使用
binding.remote_pry
代替binding.pry
- 在您的服务器上执行
bundle exec pry-remote
一旦遇到断点,你就会得到一个撬shell。
我可以使用 binding.pry
在本地调试应用程序。但我也需要在远程服务器 (webiste) 上这样做,因为在本地我没有任何错误,但在生产中我有。所以将 binding.pry
放在服务器的源文件中,当我向网站发出 post 请求时,我没有 return 任何响应,甚至当我 运行 rails console
在服务器上没有任何改变并且 rails console
.
它是一个开发服务器,所以它在互联网上可见,但它是一个开发服务器,尽管对于 rails 它是生产服务器,因为 RAIL_ENV
等于 production
。我真的需要使用 pry 在本地进行调试。我该怎么做?
更新:
# bundle exec pry-remote
/usr/lib/ruby/1.9.1/drb/drb.rb:736:in `rescue in block in open': druby://127.0.0.1:9876 - #<Errno::ECONNREFUSED: Connection refused - connect(2)> (DRb::DRbConnError)
from /usr/lib/ruby/1.9.1/drb/drb.rb:730:in `block in open'
from /usr/lib/ruby/1.9.1/drb/drb.rb:729:in `each'
from /usr/lib/ruby/1.9.1/drb/drb.rb:729:in `open'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1191:in `initialize'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1171:in `new'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1171:in `open'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1105:in `with_friend'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1086:in `method_missing'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/gems/pry-remote-0.1.8/lib/pry-remote.rb:289:in `run'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/gems/pry-remote-0.1.8/bin/pry-remote:4:in `<top (required)>'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/bin/pry-remote:19:in `load'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/bin/pry-remote:19:in `<main>'
我假设您的生产应用程序 运行 由某种守护程序应用程序服务器(例如 Puma 或 Unicorn)提供。
在此设置中,pry-remote 可以提供帮助。
- 将其添加到您的 Gemfile
- 使用
binding.remote_pry
代替binding.pry
- 在您的服务器上执行
bundle exec pry-remote
一旦遇到断点,你就会得到一个撬shell。