Skip to content

Commit

Permalink
fix: worker group string
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh6790 committed Aug 28, 2024
1 parent 284265f commit b0c1ea3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 5 additions & 5 deletions press/docker/config/supervisor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 %}

Expand Down
15 changes: 13 additions & 2 deletions press/press/doctype/deploy_candidate/deploy_candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit b0c1ea3

Please sign in to comment.