Incerteza
Incerteza

Reputation: 34934

Pry on the production server - how can I make it work there?

I can debug an app locally with binding.pry just fine. But I need to that on the remote server (webiste) as well, because locally I don't have any error but on production I do. So put binding.pry in the source file on the server and when I made a post request to the website, I didn't return any response and even when I ran rails console on the server didn't change anything and there was no output in rails console.

It's a dev server, so it's visible in the internet but it's a developer server, although for rails it's production because RAIL_ENV is equal to production. I really need to debug it the way I can do locally using pry. How can I do it?

update:

# 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>'

Upvotes: 4

Views: 4903

Answers (1)

janfoeh
janfoeh

Reputation: 10328

I assume your production app is run by some kind of daemonized application server, such as Puma or Unicorn.

In this setup, pry-remote can help.

  1. add it to your Gemfile
  2. use binding.remote_pry instead of binding.pry
  3. execute bundle exec pry-remote on your server

You'll get a pry shell as soon as the breakpoint has been hit.

Upvotes: 8

Related Questions