ngrok-tunnel
ngrok-tunnel copied to clipboard
'Ngrok::Tunnel.running?' could be determined on-the-fly
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.
Thanks for you suggestions. Pull requests are welcome!