class ForemanTasksCore::Runner::Dispatcher::RunnerActor
Public Class Methods
new(dispatcher, suspended_action, runner, clock, logger, _options = {})
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 13 def initialize(dispatcher, suspended_action, runner, clock, logger, _options = {}) @dispatcher = dispatcher @clock = clock @ticker = dispatcher.ticker @logger = logger @suspended_action = suspended_action @runner = runner @finishing = false end
Public Instance Methods
external_event(_event)
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 76 def external_event(_event) refresh_runner end
finish()
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 63 def finish @logger.debug("finish runner #{@runner.id}") @finishing = true @dispatcher.finish(@runner.id) end
kill()
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 56 def kill @logger.debug("kill runner #{@runner.id}") @runner.kill rescue => e handle_exception(e, false) end
on_envelope(*args)
click to toggle source
Calls superclass method
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 23 def on_envelope(*args) super rescue => e handle_exception(e) end
refresh_runner()
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 38 def refresh_runner @logger.debug("refresh runner #{@runner.id}") if (update = @runner.run_refresh) @suspended_action << update finish if update.exit_status end ensure @refresh_planned = false plan_next_refresh end
start_runner()
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 29 def start_runner @logger.debug("start runner #{@runner.id}") set_timeout if @runner.timeout_interval @runner.start refresh_runner ensure plan_next_refresh end
start_termination(*args)
click to toggle source
Calls superclass method
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 69 def start_termination(*args) @logger.debug("terminate #{@runner.id}") super @runner.close finish_termination end
timeout_runner()
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 49 def timeout_runner @logger.debug("timeout runner #{@runner.id}") @runner.timeout rescue => e handle_exception(e, false) end
Private Instance Methods
handle_exception(exception, fatal = true)
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 96 def handle_exception(exception, fatal = true) @dispatcher.handle_command_exception(@runner.id, exception, fatal) end
plan_next_refresh()
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 88 def plan_next_refresh if !@finishing && !@refresh_planned @logger.debug("planning to refresh #{@runner.id}") @ticker.tell([:add_event, reference, :refresh_runner]) @refresh_planned = true end end
set_timeout()
click to toggle source
# File lib/foreman_tasks_core/runner/dispatcher.rb, line 82 def set_timeout timeout_time = Time.now.getlocal + @runner.timeout_interval @logger.debug("setting timeout for #{@runner.id} to #{timeout_time}") @clock.ping(reference, timeout_time, :timeout_runner) end