Class: Ringleader::WaitForPort
- Inherits:
-
Object
- Object
- Ringleader::WaitForPort
- Includes:
- Celluloid, Celluloid::Logger
- Defined in:
- lib/ringleader/wait_for_port.rb
Instance Method Summary collapse
-
#initialize(host, port, app) ⇒ WaitForPort
constructor
A new instance of WaitForPort.
- #wait ⇒ Object
Constructor Details
#initialize(host, port, app) ⇒ WaitForPort
Returns a new instance of WaitForPort.
6 7 8 9 |
# File 'lib/ringleader/wait_for_port.rb', line 6 def initialize(host, port, app) @host, @port, @app = host, port, app async.wait end |
Instance Method Details
#wait ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ringleader/wait_for_port.rb', line 11 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 |