OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Set retry_on options for some jobs
Oliver Günther27268568f8ec
diff --git a/app/workers/mailer_job.rb b/app/workers/mailer_job.rbindex 4ac6e6411b5..f638cb16288 100644--- a/app/workers/mailer_job.rb+++ b/app/workers/mailer_job.rb@@ -45,6 +45,11 @@class MailerJob < ApplicationJobqueue_as { ActionMailer::Base.deliver_later_queue_name }+ # Retry mailing jobs three times with exponential backoff+ retry_on StandardError, wait: :exponentially_longer, attempts: 3++ # If exception is handled in mail handler+ # retry_on will be ignoredrescue_from StandardError, with: :handle_exception_with_mailer_classdef perform(mailer, mail_method, delivery_method, *args)diff --git a/modules/webhooks/app/workers/represented_webhook_job.rb b/modules/webhooks/app/workers/represented_webhook_job.rbindex bfd378b19f1..528d0b790e9 100644--- a/modules/webhooks/app/workers/represented_webhook_job.rb+++ b/modules/webhooks/app/workers/represented_webhook_job.rb@@ -51,6 +51,9 @@ class RepresentedWebhookJob < WebhookJobbeginresponse = RestClient.post webhook.url, request_body, headers+ rescue RestClient::RequestTimeout => e+ response = e.response+ exception = erescue RestClient::Exception => eresponse = e.responseexception = e@@ -69,6 +72,12 @@ class RepresentedWebhookJob < WebhookJobresponse_headers: response.try(:headers),response_body: response.try(:to_s) || exception.try(:message))++ # We want to re-raise timeout exceptions+ # but log the request beforehand+ if exception&.is_a?(RestClient::RequestTimeout)+ raise exception+ endenddef accepted_in_project?diff --git a/modules/webhooks/app/workers/webhook_job.rb b/modules/webhooks/app/workers/webhook_job.rbindex c2e16ba7af3..e4a3e617fd7 100644--- a/modules/webhooks/app/workers/webhook_job.rb+++ b/modules/webhooks/app/workers/webhook_job.rb@@ -30,6 +30,13 @@class WebhookJob < ApplicationJobattr_reader :webhook_id, :event_name+ # Retry webhook jobs three times with exponential backoff+ # in case of timeouts+ retry_on Timeout::Error,+ RestClient::RequestTimeout,+ wait: :exponentially_longer,+ attempts: 3+def perform(webhook_id, event_name)@webhook_id = webhook_id@event_name = event_name