Class: Invoker::Power::PortFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/invoker/power/port_finder.rb

Constant Summary collapse

STARTING_PORT =
23400

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePortFinder

Returns a new instance of PortFinder.



6
7
8
9
10
11
# File 'lib/invoker/power/port_finder.rb', line 6

def initialize
  @starting_port = STARTING_PORT
  @ports = []
  @dns_port = nil
  @http_port = nil
end

Instance Attribute Details

#dns_portObject

Returns the value of attribute dns_port.



5
6
7
# File 'lib/invoker/power/port_finder.rb', line 5

def dns_port
  @dns_port
end

#http_portObject

Returns the value of attribute http_port.



5
6
7
# File 'lib/invoker/power/port_finder.rb', line 5

def http_port
  @http_port
end

#https_portObject

Returns the value of attribute https_port.



5
6
7
# File 'lib/invoker/power/port_finder.rb', line 5

def https_port
  @https_port
end

#starting_portObject

Returns the value of attribute starting_port.



5
6
7
# File 'lib/invoker/power/port_finder.rb', line 5

def starting_port
  @starting_port
end

Instance Method Details

#find_portsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/invoker/power/port_finder.rb', line 13

def find_ports
  STARTING_PORT.upto(STARTING_PORT + 100) do |port|
    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