lib/pact/mock_service/server/spawn.rb in pact-mock_service-3.0.0 vs lib/pact/mock_service/server/spawn.rb in pact-mock_service-3.0.1
- old
+ new
@@ -5,27 +5,27 @@
module Server
class Spawn
class PortUnavailableError < StandardError; end
- def self.call pidfile, port, ssl = false
+ def self.call pidfile, host, port, ssl = false
if pidfile.can_start?
- if port_available? port
+ if port_available? host, port
pid = fork do
yield
end
pidfile.pid = pid
Process.detach(pid)
- Server::WaitForServerUp.(port, {ssl: ssl})
+ Server::WaitForServerUp.(host, port, {ssl: ssl})
pidfile.write
else
raise PortUnavailableError.new("ERROR: Port #{port} already in use.")
end
end
end
- def self.port_available? port
- server = TCPServer.new('127.0.0.1', port)
+ def self.port_available? host, port
+ server = TCPServer.new(host, port)
true
rescue
false
ensure
server.close if server