lib/veewee/provider/core/helper/tcp.rb in veewee-0.3.0.alpha8 vs lib/veewee/provider/core/helper/tcp.rb in veewee-0.3.0.alpha9

- old
+ new

@@ -37,11 +37,11 @@ end end if guessed_port.nil? ui.error "No free port available: tried #{min_port}..#{max_port}" - exit -1 + raise Veewee::Error, "No free port available: tried #{min_port}..#{max_port}" else ui.info "Found port #{guessed_port} available" end return guessed_port @@ -50,13 +50,15 @@ def execute_when_tcp_available(ip="127.0.0.1", options = { } , &block) defaults={ :port => 22, :timeout => 2 , :pollrate => 5} options=defaults.merge(options) + timeout=options[:timeout] + timeout=ENV['VEEWEE_TIMEOUT'].to_i unless ENV['VEEWEE_TIMEOUT'].nil? begin - Timeout::timeout(options[:timeout]) do + Timeout::timeout(timeout) do connected=false while !connected do begin ui.info "trying connection" s = TCPSocket.new(ip, options[:port]) @@ -67,10 +69,10 @@ sleep options[:pollrate] end end end rescue Timeout::Error - raise 'timeout connecting to port' + raise "Timeout connecting to TCP port {options[:port]} exceeded #{timeout} secs." end return false end