Class: ForemanTasksCore::Runner::Dispatcher::RunnerActor
- Inherits:
-
Dynflow::Actor
- Object
- Dynflow::Actor
- ForemanTasksCore::Runner::Dispatcher::RunnerActor
- Defined in:
- lib/foreman_tasks_core/runner/dispatcher.rb
Instance Method Summary collapse
- #external_event(_event) ⇒ Object
- #finish ⇒ Object
-
#initialize(dispatcher, suspended_action, runner, clock, logger, _options = {}) ⇒ RunnerActor
constructor
A new instance of RunnerActor.
- #kill ⇒ Object
- #on_envelope(*args) ⇒ Object
- #refresh_runner ⇒ Object
- #start_runner ⇒ Object
- #start_termination(*args) ⇒ Object
- #timeout_runner ⇒ Object
Constructor Details
#initialize(dispatcher, suspended_action, runner, clock, logger, _options = {}) ⇒ RunnerActor
Returns a new instance of RunnerActor.
13 14 15 16 17 18 19 20 21 |
# File 'lib/foreman_tasks_core/runner/dispatcher.rb', line 13 def initialize(dispatcher, suspended_action, runner, clock, logger, = {}) @dispatcher = dispatcher @clock = clock @ticker = dispatcher.ticker @logger = logger @suspended_action = suspended_action @runner = runner @finishing = false end |
Instance Method Details
#external_event(_event) ⇒ Object
76 77 78 |
# File 'lib/foreman_tasks_core/runner/dispatcher.rb', line 76 def external_event(_event) refresh_runner end |
#finish ⇒ Object
63 64 65 66 67 |
# 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 ⇒ Object
56 57 58 59 60 61 |
# 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) ⇒ Object
23 24 25 26 27 |
# File 'lib/foreman_tasks_core/runner/dispatcher.rb', line 23 def on_envelope(*args) super rescue => e handle_exception(e) end |
#refresh_runner ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# 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 ⇒ Object
29 30 31 32 33 34 35 36 |
# 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) ⇒ Object
69 70 71 72 73 74 |
# 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 ⇒ Object
49 50 51 52 53 54 |
# 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 |