Module: Capistrano::ASG::Rolling::SSH
- Defined in:
- lib/capistrano/asg/rolling/ssh.rb
Overview
Test the SSHKit backend for availability.
Constant Summary collapse
- WAIT_TIMEOUT =
300
Class Method Summary collapse
Class Method Details
.available?(backend) ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/capistrano/asg/rolling/ssh.rb', line 27 def available?(backend) backend.test('echo hello') true rescue ::Net::SSH::AuthenticationFailed, ::Net::SSH::Authentication::DisallowedMethod # SSH server is reachable and responding. true rescue ::Net::SSH::ConnectionTimeout, ::Net::SSH::Proxy::ConnectError, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ETIMEDOUT, Errno::ECONNRESET # SSH server not reachable or port closed. false rescue ::Net::SSH::Disconnect # rubocop:disable Lint/DuplicateBranch # SSH server is reachable, but the connection dropped unexpectedly. false end |
.wait_for_availability(backend) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/capistrano/asg/rolling/ssh.rb', line 14 def wait_for_availability(backend) timeout = WAIT_TIMEOUT expires_at = Time.now + timeout loop do break if available?(backend) raise SSHAvailabilityTimeoutError, timeout if Time.now > expires_at sleep 1 end end |