From e0e0a91e7d88cea6743f6a53f7dc5b2ca87ad115 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Thu, 4 Oct 2018 16:56:24 +0200 Subject: [PATCH] FIX: Retry sending email in case of temporary issue. (#6375) --- app/jobs/regular/notify_mailing_list_subscribers.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/jobs/regular/notify_mailing_list_subscribers.rb b/app/jobs/regular/notify_mailing_list_subscribers.rb index 747f935a0cd..93330a3c7c5 100644 --- a/app/jobs/regular/notify_mailing_list_subscribers.rb +++ b/app/jobs/regular/notify_mailing_list_subscribers.rb @@ -5,8 +5,21 @@ module Jobs class NotifyMailingListSubscribers < Jobs::Base include Skippable + RETRY_TIMES = [5.minute, 15.minute, 30.minute, 45.minute, 90.minute, 180.minute, 300.minute] + sidekiq_options queue: 'low' + sidekiq_options retry: RETRY_TIMES.size + + sidekiq_retry_in do |count, exception| + case exception.wrapped + when SocketError + RETRY_TIMES[count] + else + Jobs::UserEmail.seconds_to_delay(count) + end + end + def execute(args) return if SiteSetting.disable_mailing_list_mode