Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating remote Drb server (for use with pry-remote)

Tags:

ruby

pry

drb

I've been really enjoying developing Ruby applications with Pry. I've also seen a Pry plugin called pry-remote which lets you set up a Drb server for remote access to a Pry session. The pry-remote synopsis in the README makes sense and I have no problem running locally. But how can I use this to, for example, allow a colleague to access the same Pry session in his/her terminal?

If possible, the API I desire would be something like localtunnel:

On computer1:

$ ruby main.rb
[pry-remote] Waiting for client on druby://127.0.0.1:9876

$ drblocaltunnel 9876
share this url: 
http://xyz.drblocaltunnel.com

On computer2:

$ drblocaltunnel login -url http://xyz.drblocaltunnel.com

Frame number: 0/4

From: /programming/drb/main.rb @ line 5 Foo#initialize:

    4: def initialize(x, y)
 => 5:   binding.remote_pry
    6: end
like image 382
user94154 Avatar asked Nov 13 '22 03:11

user94154


1 Answers

You can just use

binding.remote_pry(host_string, port_number)

In your code to bind on host different from localhost. And use pry-remote -s host -p port to connect to this host from another computer. But pry-remote opens only one listening socket, so your colleague can only has access if you are not connected yet.

like image 50
Vessimir Avatar answered Nov 15 '22 06:11

Vessimir