Class: Invoker::Parsers::Config
- Inherits:
-
Object
- Object
- Invoker::Parsers::Config
- Defined in:
- lib/invoker/parsers/config.rb
Constant Summary collapse
- PORT_REGEX =
/\$PORT/
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#power_config ⇒ Object
Returns the value of attribute power_config.
-
#processes ⇒ Object
Returns the value of attribute processes.
Instance Method Summary collapse
- #autorunnable_processes ⇒ Object
- #dns_port ⇒ Object
- #http_port ⇒ Object
- #https_port ⇒ Object
-
#initialize(filename, port) ⇒ Config
constructor
initialize takes a port form cli and decrements it by 1 and sets the instance variable @port.
- #process(label) ⇒ Object
- #tld ⇒ Object
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 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
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
9 10 11 |
# File 'lib/invoker/parsers/config.rb', line 9 def filename @filename end |
#power_config ⇒ Object
Returns the value of attribute power_config.
8 9 10 |
# File 'lib/invoker/parsers/config.rb', line 8 def power_config @power_config end |
#processes ⇒ Object
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_processes ⇒ Object
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_port ⇒ Object
32 33 34 |
# File 'lib/invoker/parsers/config.rb', line 32 def dns_port power_config && power_config.dns_port end |
#http_port ⇒ Object
28 29 30 |
# File 'lib/invoker/parsers/config.rb', line 28 def http_port power_config && power_config.http_port end |
#https_port ⇒ Object
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 |
#tld ⇒ Object
40 41 42 |
# File 'lib/invoker/parsers/config.rb', line 40 def tld power_config && power_config.tld end |