2024-10-21 01:32:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class GitJob < ApplicationJob
|
2024-10-21 10:27:38 -05:00
|
|
|
include GoodJob::ActiveJobExtensions::Concurrency
|
|
|
|
|
2024-10-21 01:32:17 -05:00
|
|
|
queue_as :git
|
|
|
|
|
|
|
|
good_job_control_concurrency_with(perform_limit: 1)
|
|
|
|
|
2024-10-21 11:12:11 -05:00
|
|
|
def perform(identifier, base_path, *commands)
|
2024-10-21 01:32:17 -05:00
|
|
|
commands.each do |command|
|
2024-10-21 11:12:11 -05:00
|
|
|
system!(command, path: base_path)
|
2024-10-21 01:32:17 -05:00
|
|
|
end
|
2024-10-21 01:36:59 -05:00
|
|
|
rescue StandardError => e
|
|
|
|
ExceptionLog.add(e, source: "GitJob", identifier: identifier)
|
2024-10-21 10:36:20 -05:00
|
|
|
raise(e)
|
2024-10-21 01:32:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2024-10-21 11:12:11 -05:00
|
|
|
def system!(*, path:)
|
|
|
|
system(*, exception: true, chdir: path)
|
2024-10-21 01:32:17 -05:00
|
|
|
end
|
|
|
|
end
|