_docker/control.rb
#
# Waits for the specified supporting service to start
#
Waits for the specified supporting service to start
Waits for the specified supporting service to start
def wait_for_supporting_service_to_start(environment, service_name, service_port, service_url)
    puts "Waiting for service '#{service_name}' to start..."
    host = determine_docker_host_for_container_ports
    port = get_host_mapped_port_for_container(environment, service_name, service_port)
    target_url = "http://#{host}:#{port}/#{service_url}"
    puts "Testing access to service '#{service_name}' via URL '#{target_url}'..."
    up = false
    until up do
      begin
        sleep 2
        get_host_mapped_port_for_container(environment, service_name, service_port)
        response = Net::HTTP.get_response(URI(target_url))
        response_code = response.code.to_i
        up = response_code < 400
      rescue
        up = false
      end
    end
    puts "Service '#{service_name}' is up on '#{target_url}'"
    [host, port]
end
def wait_for_supporting_service_to_start ( environment , service_name , service_port , service_url ) puts "Waiting for service '#{service_name}' to start..." host = determine_docker_host_for_container_ports port = get_host_mapped_port_for_container ( environment , service_name , service_port ) target_url = "http://#{host}:#{port}/#{service_url}" puts "Testing access to service '#{service_name}' via URL '#{target_url}'..." up = false until up do begin sleep 2 get_host_mapped_port_for_container ( environment , service_name , service_port ) response = Net :: HTTP . get_response ( URI ( target_url ) ) response_code = response . code . to_i up = response_code < 400 rescue up = false end end puts "Service '#{service_name}' is up on '#{target_url}'" [ host , port ] end
Waits for the specified supporting service to start
Waits for the specified supporting service to start
# Firstly, sleep so we don't bombard the service with requests and then check the container is still running # Then try accessing the service on the target_url. Anything other than a non-400 status code means its not up
environment
service_name
service_port
service_url