From bba787c06e53ab80fdba2371d72bd45faee59553 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Tue, 28 Mar 2023 11:48:13 +0000 Subject: [PATCH] Ensure all Sidekiq queues are always alive --- mastodon.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mastodon.nix b/mastodon.nix index 9a5037b..8e2c327 100644 --- a/mastodon.nix +++ b/mastodon.nix @@ -36,6 +36,7 @@ let sidekiq-manager = pkgs.writers.writePython3 "sidekiq-manager" {} '' from itertools import permutations from subprocess import Popen + from time import sleep def sidekiq(queues, connections=16): @@ -52,6 +53,17 @@ let queues = ['default', 'push', 'ingress'] procs += [sidekiq(qs) for qs in permutations(queues)] + for p in procs: + sleep(1) + if p.poll(): + # one of the queues is dead + break + + # terminate the rest queues + for p in procs: + # https://github.com/sidekiq/sidekiq/wiki/Signals#term + p.terminate() + for p in procs: p.wait() '';