From 512589f6361a3545aaa911b4ec195bc7dd0e02de Mon Sep 17 00:00:00 2001 From: didier Date: Wed, 9 Apr 2025 14:22:47 +0200 Subject: [PATCH] add wait for workers to be ready --- install.sh | 3 +++ pandora-box.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/install.sh b/install.sh index 9770289..2dcb346 100755 --- a/install.sh +++ b/install.sh @@ -153,6 +153,9 @@ su - $SUDO_USER -c "cd ~/pandora/pandora/workers; cp yarahub.yml.sample yarahq_f # Increase the number of replica su - $SUDO_USER -c "cd ~/pandora/pandora/workers; sed -i 's/replicas: 1/replicas: 5/' base.yml" +# Disable UNO Server -> "disable_unoserver": true, +su - $SUDO_USER -c "cd ~/pandora/config; sed -i 's/\"disable_unoserver\"\: false/\"disable_unoserver\"\: true/' generic.json" + # remove some workers # rm pandora/workers/preview.yml diff --git a/pandora-box.py b/pandora-box.py index 80763c6..6c06833 100755 --- a/pandora-box.py +++ b/pandora-box.py @@ -875,10 +875,29 @@ def get_lock(process_name): # -------------------------------------- +def get_enabled_workers(): + config_dir = Path("~/pandora/pandora/workers") + yml_files = list(config_dir.glob("*.yml")) + return [file.stem for file in yml_files] + +def wait_for_workers(): + target_count = get_enabled_workers() - 1 + while True: + workers = self.pandora.get_enabled_workers() + log(f"Workers ready : {len(workers)}/ {target_count}") + if len(workers) >= target_count: + break + time.sleep(2) + +# -------------------------------------- + def main(_): """Main entry point""" print("main") try: + # Wait for workers to start + + # Enter the mail loop state = "START" while state != "STOP": state = loop(state)