Class: Barbeque::MessageHandler::JobExecution
- Inherits:
-
Object
- Object
- Barbeque::MessageHandler::JobExecution
- Defined in:
- lib/barbeque/message_handler/job_execution.rb
Instance Method Summary collapse
-
#initialize(message:, job_queue:) ⇒ JobExecution
constructor
A new instance of JobExecution.
- #run ⇒ Object
Constructor Details
#initialize(message:, job_queue:) ⇒ JobExecution
Returns a new instance of JobExecution.
11 12 13 14 |
# File 'lib/barbeque/message_handler/job_execution.rb', line 11 def initialize(message:, job_queue:) @message = @job_queue = job_queue end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/barbeque/message_handler/job_execution.rb', line 16 def run begin job_execution = Barbeque::JobExecution.create(message_id: @message.id, job_definition: job_definition, job_queue: @job_queue) rescue ActiveRecord::RecordNotUnique => e raise DuplicatedExecution.new(e.) end stdout, stderr, status = run_command job_execution.update!(status: status.success? ? :success : :failed, finished_at: Time.now) notify_slack(job_execution, status) log_result(job_execution, stdout, stderr) end |