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.
This commit is contained in:
Guo Xiang Tan 2020-06-23 15:42:04 +08:00
parent e92909aa77
commit 27b2e335ef
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20

View File

@ -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