define max_attempts for jobs

This commit is contained in:
Christophe Robillard 2020-06-02 20:13:38 +02:00
parent 95f925f5f7
commit 705487dab6
11 changed files with 24 additions and 8 deletions

View file

@ -1,4 +1,6 @@
class ApplicationJob < ActiveJob::Base
DEFAULT_MAX_ATTEMPTS_JOBS = 25
before_perform do |job|
Rails.logger.info("#{job.class.name} started at #{Time.zone.now}")
end
@ -18,4 +20,8 @@ class ApplicationJob < ActiveJob::Base
def error(job, exception)
Raven.capture_exception(exception)
end
def max_attempts
ENV["MAX_ATTEMPTS_JOBS"].to_i || DEFAULT_MAX_ATTEMPTS_JOBS
end
end