Websites/app/jobs/git_job.rb

25 lines
517 B
Ruby
Raw Normal View History

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)
def perform(identifier, *commands)
2024-10-21 06:32:17 +00:00
commands.each do |command|
system!(command)
end
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
def system!(*)
2024-10-21 15:36:20 +00:00
system(*, exception: true, chdir: Websites.config.yiffy2_storage.base_path)
2024-10-21 06:32:17 +00:00
end
end