Websites/app/jobs/git_job.rb

25 lines
516 B
Ruby
Raw Normal View History

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
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