From 68b45c054b5d221746cd02bd17d37e1b4d4df41e Mon Sep 17 00:00:00 2001 From: Anton Boritskiy Date: Mon, 16 Nov 2020 23:26:18 +0100 Subject: [PATCH] ADHOC feat queue-cron-management: add wait for consumers var as the comment states it: sometimes we don't want our consumers to wait for messages, cause it allows to reduce project memory usage. --- defaults/main.yml | 4 ++++ templates/etc/env.php.j2 | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 6a6da0f..273d79f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -289,6 +289,10 @@ magento_upgrade_commands: ## See https://magento.stackexchange.com/questions/285385/magento-2-3-2-ce-and-cron-jobs-flock-and-rabbitmq/285386#285386 magento_run_message_queue_consumers_separately: false +## in case you don't want message queue consumers to wait for messages - change this to false +## Changing it to false reduces server memory consuption but increases the waiting time for messages to be processed. +magento_queue_consumers_wait_for_messages: true + magento_queue_consumers_cron_template: "/usr/bin/php {{ magento_app_root }}/bin/magento queue:consumers:start {{ item.name }}" ## Deletes all installed deployable magento packages except the diff --git a/templates/etc/env.php.j2 b/templates/etc/env.php.j2 index 60ea7ff..de94a1c 100644 --- a/templates/etc/env.php.j2 +++ b/templates/etc/env.php.j2 @@ -113,9 +113,10 @@ return array ( array ( 'date' => '{{ magento_install_date }}', ), - {% if magento_queue_amqp is defined %} 'queue' => array ( + 'consumers_wait_for_messages' => {{ magento_queue_consumers_wait_for_messages }}, + {% if magento_queue_amqp is defined %} 'amqp' => array ( 'host' => '{{ magento_queue_amqp.host }}', @@ -125,8 +126,8 @@ return array ( 'virtualhost' => '{{ magento_queue_amqp.virtualhost }}', 'ssl' => '{{ magento_queue_amqp.ssl }}', ), + {% endif %} ), - {% endif %} {% if magento_run_message_queue_consumers_separately %} 'cron_consumers_runner' => array( 'cron_run' => false