Class: Executo::Worker
- Inherits:
-
Object
- Object
- Executo::Worker
- Includes:
- TaggedLogger, Sidekiq::Worker
- Defined in:
- lib/executo/worker.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#flushable_output ⇒ Object
readonly
Returns the value of attribute flushable_output.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
Instance Attribute Details
#flushable_output ⇒ Object (readonly)
Returns the value of attribute flushable_output.
8 9 10 |
# File 'lib/executo/worker.rb', line 8 def flushable_output @flushable_output end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/executo/worker.rb', line 8 def @options end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
8 9 10 |
# File 'lib/executo/worker.rb', line 8 def output @output end |
Instance Method Details
#perform(command, params = [], options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/executo/worker.rb', line 13 def perform(command, params = [], = {}) @options = @output ||= Hash.new([]) @flushable_output ||= Hash.new([]) @started_at = Time.current @flushed_at = Time.current logger_add_tag('Worker') logger_add_tag(.dig('feedback', 'id')) logger_add_tag(command) logger.debug "params: #{params}" logger.debug "options: #{}" send_feedback(state: 'started') status = execute(command, params, ) send_feedback( state: status.success? ? 'completed' : 'failed', exitstatus: status.exitstatus.to_i, stdout: output[:stdout], stderr: output[:stderr], pid: status.pid ) rescue StandardError => e logger.error "Exception: #{e.class} - #{e.}" logger.error e.backtrace.join("\n") send_feedback(state: 'failed') ensure send_feedback(state: 'finished') end |