From 1cfaa359115666ed26b05813834b1e0979782381 Mon Sep 17 00:00:00 2001 From: Aradhya-Tripathi Date: Fri, 21 Mar 2025 13:50:10 +0530 Subject: [PATCH] feat: stopping and starting worker exec before and after build --- agent/bench.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/agent/bench.py b/agent/bench.py index c46d914d..ab89944c 100644 --- a/agent/bench.py +++ b/agent/bench.py @@ -511,15 +511,34 @@ def restart(self, web_only=False): def rebuild_job(self): return self.rebuild() + @step("Stop All Worker Execution") + def stop_worker_execution(self): + self.docker_execute("supervisorctl stop all") + + @step("Start All Worker Execution") + def start_worker_execution(self): + self.docker_execute("supervisorctl start all") + @step("Rebuild Bench Assets") def rebuild(self, apps: list[str] | None = None): - if not apps: - return self.docker_execute("bench build") - - if len(apps) == 1: - return self.docker_execute(f"bench build --app {apps[0]}") + self.stop_worker_execution() - return self.docker_execute(f"bench build --apps {','.join(apps)}") + try: + if not apps: + build_result = self.docker_execute("bench build") + self.start_worker_execution() + return build_result + + if len(apps) == 1: + build_result = self.docker_execute(f"bench build --app {apps[0]}") + self.start_worker_execution() + return build_result + + build_result = self.docker_execute(f"bench build --apps {','.join(apps)}") + self.start_worker_execution() + return build_result + except Exception: + self.start_worker_execution() @property def apps(self):