Method: Beaker::Host#wait_for_port

Defined in:
lib/beaker/host.rb

#wait_for_port(port, attempts = 15) ⇒ Object

Wait for a port on the host. Useful for those occasions when you’ve called host.reboot and want to avoid spam from subsequent SSH connections retrying to connect from say retry_on()



107
108
109
110
111
112
113
114
115
116
117
# File 'lib/beaker/host.rb', line 107

def wait_for_port(port, attempts = 15)
  @logger.debug("  Waiting for port #{port} ... ", false)
  start = Time.now
  done = repeat_fibonacci_style_for(attempts) { port_open?(port) }
  if done
    @logger.debug(format('connected in %0.2f seconds', (Time.now - start)))
  else
    @logger.debug('timeout')
  end
  done
end