lib/invoker/power/port_finder.rb in invoker-1.1.0 vs lib/invoker/power/port_finder.rb in invoker-1.2.0.pre
- old
+ new
@@ -1,31 +1,33 @@
module Invoker
module Power
class PortFinder
STARTING_PORT = 23400
- attr_accessor :dns_port, :http_port, :starting_port
+ attr_accessor :dns_port, :http_port, :starting_port, :https_port
def initialize
@starting_port = STARTING_PORT
@ports = []
@dns_port = nil
@http_port = nil
end
def find_ports
STARTING_PORT.upto(STARTING_PORT + 100) do |port|
- break if @ports.size > 2
+ break if @ports.size > 3
if check_if_port_is_open(port)
@ports << port
else
next
end
end
@dns_port = @ports[0]
@http_port = @ports[1]
+ @https_port = @ports[2]
end
private
+
def check_if_port_is_open(port)
socket_flag = true
sockets = nil
begin
sockets = Socket.tcp_server_sockets(port)
@@ -40,10 +42,8 @@
def close_socket_pairs(sockets)
sockets.each { |s| s.close }
rescue
nil
end
-
-
end
end
end