Sha256: 0e3e1bb48ec621db4b5d31d3cebe9eb19464ecf041fcde418d294d5965c6650d

Contents?: true

Size: 633 Bytes

Versions: 6

Compression:

Stored size: 633 Bytes

Contents

module Ringleader
  class WaitForPort
    include Celluloid
    include Celluloid::Logger

    def initialize(host, port, app)
      @host, @port, @app = host, port, app
      async.wait
    end

    def wait
      begin
        TCPSocket.new @host, @port
      rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT
        debug "#{@host}:#{@port} not open yet"
        sleep 0.5
        retry
      rescue IOError, SystemCallError => e
        error "unexpected error while waiting for port: #{e}"
        sleep 0.5
        retry
      end
      debug "#{@host}:#{@port} open"
      @app.async.port_opened
      terminate
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ringleader-1.1.8 lib/ringleader/wait_for_port.rb
ringleader-1.1.7 lib/ringleader/wait_for_port.rb
ringleader-1.1.6 lib/ringleader/wait_for_port.rb
ringleader-1.1.5 lib/ringleader/wait_for_port.rb
ringleader-1.1.5.pre2 lib/ringleader/wait_for_port.rb
ringleader-1.1.5.pre1 lib/ringleader/wait_for_port.rb