From e12f53d1a56d598d90307bdfa755db02cc37a30c Mon Sep 17 00:00:00 2001 From: Francisco Roldan Date: Mon, 30 Aug 2021 12:35:53 -0300 Subject: [PATCH 1/2] feat: added option to provide custom queues --- bench/config/supervisor.py | 1 + bench/config/templates/supervisor.conf | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/bench/config/supervisor.py b/bench/config/supervisor.py index 8c036624..9aa1a2be 100644 --- a/bench/config/supervisor.py +++ b/bench/config/supervisor.py @@ -42,6 +42,7 @@ def generate_supervisor_config(bench_path, user=None, yes=False, skip_redis=Fals "background_workers": config.get('background_workers') or 1, "bench_cmd": which('bench'), "skip_redis": skip_redis, + "custom_queues": config.get("custom_queues", {}), }) conf_path = os.path.join(bench_path, 'config', 'supervisor.conf') diff --git a/bench/config/templates/supervisor.conf b/bench/config/templates/supervisor.conf index d24b1cb6..06872b00 100644 --- a/bench/config/templates/supervisor.conf +++ b/bench/config/templates/supervisor.conf @@ -65,6 +65,22 @@ killasgroup=true numprocs={{ background_workers }} process_name=%(program_name)s-%(process_num)d +{% for queue_name, queue_details in custom_queues.items() %} +[program:{{ bench_name }}-frappe-{{ queue_name }}-worker] +command={{ bench_cmd }} worker --queue {{ queue_name }} +priority=4 +autostart=true +autorestart=true +stdout_logfile={{ bench_dir }}/logs/worker.log +stderr_logfile={{ bench_dir }}/logs/worker.error.log +user={{ user }} +stopwaitsecs={{ queue_details["timeout"] }} +directory={{ bench_dir }} +killasgroup=true +numprocs={{ queue_details["workers"] or background_workers }} +process_name=%(program_name)s-%(process_num)d +{% endfor %} + {% else %} [program:{{ bench_name }}-frappe-workerbeat] command={{ bench_dir }}/env/bin/python -m frappe.celery_app beat -s beat.schedule From 75f84625ad4b19f74bffa989c878ecda07b5c68b Mon Sep 17 00:00:00 2001 From: Francisco Roldan Date: Tue, 14 Sep 2021 08:42:06 -0300 Subject: [PATCH 2/2] fix: rename key --- bench/config/supervisor.py | 2 +- bench/config/templates/supervisor.conf | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bench/config/supervisor.py b/bench/config/supervisor.py index 9aa1a2be..cfbaebbd 100644 --- a/bench/config/supervisor.py +++ b/bench/config/supervisor.py @@ -42,7 +42,7 @@ def generate_supervisor_config(bench_path, user=None, yes=False, skip_redis=Fals "background_workers": config.get('background_workers') or 1, "bench_cmd": which('bench'), "skip_redis": skip_redis, - "custom_queues": config.get("custom_queues", {}), + "workers": config.get("workers", {}), }) conf_path = os.path.join(bench_path, 'config', 'supervisor.conf') diff --git a/bench/config/templates/supervisor.conf b/bench/config/templates/supervisor.conf index 06872b00..085cc2cf 100644 --- a/bench/config/templates/supervisor.conf +++ b/bench/config/templates/supervisor.conf @@ -65,19 +65,19 @@ killasgroup=true numprocs={{ background_workers }} process_name=%(program_name)s-%(process_num)d -{% for queue_name, queue_details in custom_queues.items() %} -[program:{{ bench_name }}-frappe-{{ queue_name }}-worker] -command={{ bench_cmd }} worker --queue {{ queue_name }} +{% for worker_name, worker_details in workers.items() %} +[program:{{ bench_name }}-frappe-{{ worker_name }}-worker] +command={{ bench_cmd }} worker --queue {{ worker_name }} priority=4 autostart=true autorestart=true stdout_logfile={{ bench_dir }}/logs/worker.log stderr_logfile={{ bench_dir }}/logs/worker.error.log user={{ user }} -stopwaitsecs={{ queue_details["timeout"] }} +stopwaitsecs={{ worker_details["timeout"] }} directory={{ bench_dir }} killasgroup=true -numprocs={{ queue_details["workers"] or background_workers }} +numprocs={{ worker_details["background_workers"] or background_workers }} process_name=%(program_name)s-%(process_num)d {% endfor %}