Class: InstanceAgent::Runner::Child
- Inherits:
-
ProcessManager::Daemon::Child
- Object
- ProcessManager::Daemon::Child
- InstanceAgent::Runner::Child
- Defined in:
- lib/instance_agent/runner/child.rb
Constant Summary collapse
- AGENTS =
{ 0 => InstanceAgent::CodeDeployPlugin::CommandPoller }
Instance Attribute Summary collapse
-
#runner ⇒ Object
Returns the value of attribute runner.
Instance Method Summary collapse
- #description ⇒ Object
- #prepare_run ⇒ Object
- #run ⇒ Object
- #validate_index ⇒ Object
- #with_error_handling ⇒ Object
Instance Attribute Details
#runner ⇒ Object
Returns the value of attribute runner.
11 12 13 |
# File 'lib/instance_agent/runner/child.rb', line 11 def runner @runner end |
Instance Method Details
#description ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/instance_agent/runner/child.rb', line 27 def description if runner "#{runner.description} of master #{master_pid.inspect}" else 'booting child' end end |
#prepare_run ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/instance_agent/runner/child.rb', line 13 def prepare_run validate_index with_error_handling do @runner = AGENTS[index].runner ProcessManager.set_program_name(description) end end |
#run ⇒ Object
21 22 23 24 25 |
# File 'lib/instance_agent/runner/child.rb', line 21 def run with_error_handling do runner.run end end |
#validate_index ⇒ Object
35 36 37 |
# File 'lib/instance_agent/runner/child.rb', line 35 def validate_index raise ArgumentError, "Invalid index #{index.inspect}: only 0-2 possible" unless AGENTS.keys.include?(index) end |
#with_error_handling ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/instance_agent/runner/child.rb', line 39 def with_error_handling yield rescue SocketError => e ProcessManager::Log.info "#{description}: failed to run as the connection failed! #{e.class} - #{e.} - #{e.backtrace.join("\n")}" sleep ProcessManager::Config.config[:wait_after_connection_problem] exit 1 rescue Exception => e if (e..to_s.match(/throttle/i) || e..to_s.match(/rateexceeded/i) rescue false) ProcessManager::Log.error "#{description}: ran into throttling - waiting for #{ProcessManager::Config.config[:wait_after_throttle_error]}s until retrying" sleep ProcessManager::Config.config[:wait_after_throttle_error] else ProcessManager::Log.error "#{description}: error during start or run: #{e.class} - #{e.} - #{e.backtrace.join("\n")}" end exit 1 end |