Class: SaucelabsAdapter::SshTunnel
- Includes:
- Utilities
- Defined in:
- lib/saucelabs_adapter/tunnels/ssh_tunnel.rb
Instance Method Summary collapse
Methods included from Utilities
#debug, #diagnostics_prefix, #find_unused_port, #kill_mongrel_if_needed, #raise_with_message, #say, #setup_tunnel, #start_mongrel, #teardown_tunnel
Methods inherited from Tunnel
Constructor Details
This class inherits a constructor from SaucelabsAdapter::Tunnel
Instance Method Details
#shutdown ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/saucelabs_adapter/tunnels/ssh_tunnel.rb', line 16 def shutdown # We have experienced problems with the tunnel shutdown hanging. # Previously the method was a no-op and we just exited the process which had the effect of closing the tunnel. # However we are now running multiple tunnels in one process (sequentially), so we need to actually do a shutdown. # So let's add a timeout. if @gateway begin Timeout::timeout(15) do say "Shutting down ssh reverse tunnel" @gateway.close_remote(*@host_and_port) if @host_and_port @gateway.shutdown! if @gateway end rescue Timeout::Error say "tunnel shutdown timed out" end end end |
#start_tunnel ⇒ Object
9 10 11 12 13 14 |
# File 'lib/saucelabs_adapter/tunnels/ssh_tunnel.rb', line 9 def start_tunnel say "Setting up SSH reverse tunnel from #{@se_config.application_address}:#{@se_config.application_port} to localhost:#{@se_config.tunnel_to_localhost_port}" = @se_config.tunnel_password ? { :password => @se_config.tunnel_password } : { :keys => @se_config.tunnel_keyfile } @gateway = Net::SSH::Gateway.new(@se_config.application_address, @se_config.tunnel_username, ) @host_and_port = @gateway.open_remote(@se_config.tunnel_to_localhost_port.to_i, "127.0.0.1", @se_config.application_port.to_i, "0.0.0.0") end |