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