diff --git a/press/docker/config/supervisor.conf b/press/docker/config/supervisor.conf index 7387cdebe40..d1b61b35b4c 100644 --- a/press/docker/config/supervisor.conf +++ b/press/docker/config/supervisor.conf @@ -163,9 +163,9 @@ process_name=%(program_name)s-%(process_num)d {% endif %} -{% if custom_workers_config %} +{% if custom_workers %} -{% for worker_name, worker_details in custom_workers_config.items() %} +{% for worker_name, config in custom_workers.items() %} [program:-frappe-bench-{{ worker_name }}-worker] command=bench worker --queue {{ worker_name }} priority=4 @@ -174,7 +174,7 @@ autorestart=true stdout_logfile=/home/frappe/frappe-bench/logs/{{ worker_name }}.log stderr_logfile=/home/frappe/frappe-bench/logs/{{ worker_name }}.error.log user=frappe -stopwaitsecs={{ worker_details["timeout"] }} +stopwaitsecs={{ config["timeout"] }} directory=/home/frappe/frappe-bench killasgroup=true numprocs=1 @@ -234,10 +234,10 @@ programs=frappe-bench-frappe-schedule,frappe-bench-frappe-default-worker,frappe- {% endif %} -{% if custom_workers_config %} +{% if custom_workers_group %} [group:frappe-bench-custom_workers] -programs={%- for worker_name in workers -%}frappe-bench-{{ worker_name }}-worker,{%- endfor %} +programs={{ custom_workers_group}} {% endif %} diff --git a/press/press/doctype/deploy_candidate/deploy_candidate.py b/press/press/doctype/deploy_candidate/deploy_candidate.py index 8b4b5d6eb9d..351d37eb022 100644 --- a/press/press/doctype/deploy_candidate/deploy_candidate.py +++ b/press/press/doctype/deploy_candidate/deploy_candidate.py @@ -1175,10 +1175,14 @@ def _generate_supervisor_config(self, rg): supervisor_conf = os.path.join(self.build_directory, "config", "supervisor.conf") with open(supervisor_conf, "w") as f: supervisor_conf_template = "press/docker/config/supervisor.conf" - custom_workers_config = self._get_custom_workers(rg) + custom_workers = self._get_custom_workers(rg) content = frappe.render_template( supervisor_conf_template, - {"doc": self, "custom_workers_config": custom_workers_config}, + { + "doc": self, + "custom_workers": custom_workers, + "custom_workers_group": self._get_custom_workers_group(custom_workers), + }, is_path=True, ) f.write(content) @@ -1190,6 +1194,13 @@ def _get_custom_workers(self, rg): if "workers" in common_site_config: return common_site_config["workers"] + def _get_custom_workers_group(self, custom_workers): + group = [] + if custom_workers: + for worker_name in custom_workers: + group.append(f"frappe-bench-{ worker_name }-worker") + return ", ".join(group) + def _generate_apps_txt(self): apps_txt = os.path.join(self.build_directory, "apps.txt") with open(apps_txt, "w") as f: