Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the user to specify a range of ports to use for child processes (Commit included) #73

Closed
caleb opened this issue Sep 29, 2015 · 7 comments

Comments

@caleb
Copy link

caleb commented Sep 29, 2015

Hi,

First, I wanted to thank you for this cool gem. I'm moving over to RubyMine and the ability to do debugging easily in the IDE is very cool, even when I'm running my app in a docker container.

The only problem I have is that I am using an application server (Unicorn) that spawns multiple children, and the way ruby-debug-ide works now is that it picks a random port from the ephemeral port range for each child process and I don't really want to open all the possible ports to my docker container.

I made a branch where I added a flag (--child-process-ports MIN-MAX) that lets the user specify a port range to use and whenever a child process is created it will pick a random port from that range that is open and use that instead. This way I can open up a few ports in docker and use that range for ruby-debug-ide, knowing that my unicorn will only ever have a few child processes.

Here's the commit:

https://github.com/caleb/ruby-debug-ide/commit/4dcbef9962c1c67fc0b36717cd97594ca5e0c946

I didn't make a PR because I wanted to get your opinion on this feature.

Thanks again, I'm using this gem now by simply using a single process web server in development, but I'd like to use my production setup(-ish) in development if possible.

-Caleb

@denofevil
Copy link
Member

Have you tried adding ruby from your container via remote interpreter integration? It will require only one open port for SSH connection and will push all required connections via SSH tunnel

@caleb
Copy link
Author

caleb commented Sep 29, 2015

@denofevil I haven't. I saw that that was a thing, but didn't quite understand it. So I would have to add SSH to my container and then use RubyMine to launch my Unicorn server (using the remote ruby) and it would just do the right thing?

Would that mean I wouldn't need this gem?

@denofevil
Copy link
Member

@caleb, yes, you'll need just SSH to your container. The gem will be installed automatically and you won't need to specify port settings manually

@caleb
Copy link
Author

caleb commented Sep 29, 2015

Cool! I'll give that a whirl. Thanks!

UPDATE: This is very cool once I got it set up!

@caleb caleb closed this as completed Sep 29, 2015
@jthele
Copy link

jthele commented Jun 23, 2017

I'm facing a very similar problem of debugging against a Rails application in a container. I appreciate that there is a workaround using SSH (and will investigate that path), but I also think the ability to control which ports are used for child process debugging could be a useful feature. Is that firmly not the direction you want to take ruby-debug-ide, or would you consider the the proposed solution @caleb presented in his commit? Container development often has a philosophy of minimal containers with minimal services, so having an SSH service readily available is not as much as a given as it would be for typical remote server integrations.

@noizex
Copy link

noizex commented Jul 18, 2017

I agree, this would be useful option - I actually figured out the same solution even before I ran into this issue. There was a problem with debugging session hanging and I tracked it down to this subprocess spawning and opening a random port, to which RubyMine had no access (because I'm also using Docker container with only certain ports being forwarded).

I'm looking into SSH solution, but I don't really understand how it works with ruby-debug-ide - @caleb since you figured it out could you share some tips?

Having a list of ports supplied to ruby-debug-ide instead of picking random port wouldn't hurt as an additional functionality though. It can fallback to random ports once the pool is exhausted, and it will probably require returning ports to the pool if process exits, so it may require a bit more work to be robust and bullet-proof.

PS. Actually setting SSHD connection to Docker container is not that trivial either :(

@mrbiggred
Copy link

I posted a potential workaround that does not involve setting up SSH in your Docker container in issue #107:

#107 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants