chore(job): config delayed job for long-living export jobs
This commit is contained in:
parent
6b87c290cb
commit
86f15b8c05
3 changed files with 12 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
||||
|
|
4
config/initializers/delayed_job.rb
Normal file
4
config/initializers/delayed_job.rb
Normal 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
|
Loading…
Reference in a new issue