chore(job): config delayed job for long-living export jobs

This commit is contained in:
Colin Darie 2023-03-08 18:31:34 +01:00
parent 6b87c290cb
commit 86f15b8c05
3 changed files with 12 additions and 0 deletions

View file

@ -21,6 +21,10 @@ class ApplicationJob < ActiveJob::Base
ENV.fetch("MAX_ATTEMPTS_JOBS", DEFAULT_MAX_ATTEMPTS_JOBS).to_i
end
def max_run_time
4.hours # decrease run time by default
end
def request_id
@request_id ||= Current.request_id
end

View file

@ -7,6 +7,10 @@ class ExportJob < ApplicationJob
Sentry.set_tags(procedure: job.arguments.first.procedure.id)
end
def max_run_time
Export::MAX_DUREE_GENERATION
end
def perform(export)
return if export.generated?

View file

@ -0,0 +1,4 @@
# Set max_run_time at the highest job duration we want,
# then at job level we'll decrease this value to a lower value
# except for ExportJob.
Delayed::Worker.max_run_time = 16.hours # same as Export::MAX_DUREE_GENERATION but we can't yet use this constant here