Module: Chef::MonitWrapper::Wait

Defined in:
libraries/wait.rb

Overview

Tools for waiting for events to happen.

Instance Method Summary collapse

Instance Method Details

#wait_for_host_port(host_port) ⇒ Object

Wait for the given host to start listening on the given TCP port.

Parameters:

  • host_port (String)

    a <host>:<port> string.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'libraries/wait.rb', line 21

def wait_for_host_port(host_port)
  return if host_port.nil?

  unless host_port =~ /^[^:]+:\d+$/
    raise "Expected a host:port pair instead of '#{host_port}'"
  end
  host, port = host_port.split(':')
  port = port.to_i
  require 'waitutil'
  Chef::Log.info("Waiting for host/port #{host_port}")
  WaitUtil.wait_for_service(host_port, host, port)
end