Class: Invoker::Parsers::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/invoker/parsers/config.rb

Constant Summary collapse

PORT_REGEX =
/\$PORT/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, port) ⇒ Config

initialize takes a port form cli and decrements it by 1 and sets the instance variable @port. This port value is used as the environment variable $PORT mentioned inside invoker.ini. When method pick_port gets fired it increments the value of port by 1, subsequently when pick_port again gets fired, for another command, it will again increment port value by 1, that way generating different ports for different commands.



17
18
19
20
21
22
23
24
25
26
# File 'lib/invoker/parsers/config.rb', line 17

def initialize(filename, port)
  @filename = filename || autodetect_config_file
  print_message_and_abort if invalid_config_file?

  @port = port - 1
  @processes = load_config
  if Invoker.can_run_balancer?
    @power_config = Invoker::Power::Config.load_config()
  end
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



9
10
11
# File 'lib/invoker/parsers/config.rb', line 9

def filename
  @filename
end

#power_configObject

Returns the value of attribute power_config.



8
9
10
# File 'lib/invoker/parsers/config.rb', line 8

def power_config
  @power_config
end

#processesObject

Returns the value of attribute processes.



8
9
10
# File 'lib/invoker/parsers/config.rb', line 8

def processes
  @processes
end

Instance Method Details

#autorunnable_processesObject



44
45
46
47
# File 'lib/invoker/parsers/config.rb', line 44

def autorunnable_processes
  process_to_run = processes.reject(&:disable_autorun)
  process_to_run.sort_by { |process| process.index }
end

#dns_portObject



32
33
34
# File 'lib/invoker/parsers/config.rb', line 32

def dns_port
  power_config && power_config.dns_port
end

#http_portObject



28
29
30
# File 'lib/invoker/parsers/config.rb', line 28

def http_port
  power_config && power_config.http_port
end

#https_portObject



36
37
38
# File 'lib/invoker/parsers/config.rb', line 36

def https_port
  power_config && power_config.https_port
end

#process(label) ⇒ Object



49
50
51
# File 'lib/invoker/parsers/config.rb', line 49

def process(label)
  processes.detect { |pconfig| pconfig.label == label }
end

#tldObject



40
41
42
# File 'lib/invoker/parsers/config.rb', line 40

def tld
  power_config && power_config.tld
end