ngrok-tunnel icon indicating copy to clipboard operation
ngrok-tunnel copied to clipboard

'Ngrok::Tunnel.running?' could be determined on-the-fly

Open lukehorvat opened this issue 9 years ago • 1 comments

Hi. I've built a gem for localtunnel (an ngrok alternative), using your gem as inspiration. So thanks!

Looking at your code, one thing I noticed is that there is a potential problem with the Ngrok::Tunnel.running? method. If something else (other than Ngrok::Tunnel.stop) kills the tunnel's process, Ngrok::Tunnel.running? will continue to return true, because the @status attribute is stale. To fix this, Ngrok::Tunnel.running? could check whether the process is actually alive via Process.waitpid. Here's an example from my gem: link.

Also, I think it may be a good idea for Ngrok::Tunnel.stop? to wait until the process is completely destroyed after calling Process.kill, since it can take a few moments. Again, here's an example from my gem: link.

lukehorvat avatar Oct 12 '15 14:10 lukehorvat

Thanks for you suggestions. Pull requests are welcome!

bogdanovich avatar Oct 31 '15 04:10 bogdanovich