DEV: Retry on distributed mutex timeout error when starting sidekiq.

DEV: Retry on distributed mutex timeout error when starting sidekiq.

We need Sidekiq to start mini_scheduler no matter what. Timeouts happen when trying to boot an app with Redis in readonly mode.

diff --git a/config/initializers/100-sidekiq.rb b/config/initializers/100-sidekiq.rb
index 8923807..6d6e0dd 100644
--- a/config/initializers/100-sidekiq.rb
+++ b/config/initializers/100-sidekiq.rb
@@ -70,7 +70,12 @@ if Sidekiq.server?
     scheduler_hostname = ENV["UNICORN_SCHEDULER_HOSTNAME"]
 
     if !scheduler_hostname || scheduler_hostname.split(',').include?(Discourse.os_hostname)
-      MiniScheduler.start(workers: GlobalSetting.mini_scheduler_workers)
+      begin
+        MiniScheduler.start(workers: GlobalSetting.mini_scheduler_workers)
+      rescue MiniScheduler::DistributedMutex::Timeout
+        sleep 5
+        retry
+      end
     end
   end
 end

GitHub sha: 27b2e335