Ensure all Sidekiq queues are always alive

This commit is contained in:
dump_stack() 2023-03-28 11:48:13 +00:00
parent d81754f391
commit bba787c06e
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -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()
'';