From badd6081366e4650ebd0f25ed4cd143f234f1bb4 Mon Sep 17 00:00:00 2001 From: Samuel Walladge Date: Wed, 11 Mar 2020 23:58:38 +1030 Subject: [PATCH] Allow overriding broker heartbeat (#21567) BROKER_HEARTBEAT appears to interfere with the celery worker configuration. If we want to disable or change the heartbeat interval, It must be from these configuration options. Just setting --without-heartbeat and/or --heartbeat-interval on the workers does not fully work. Eg. --without-heartbeat disables sending heartbeats, but BROKER_HEARTBEAT = 60 means that the connection will get a 60s heartbeat interval negotiated. --- cms/envs/production.py | 4 ++-- lms/envs/production.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cms/envs/production.py b/cms/envs/production.py index aa254585e6..23da28ebf2 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -96,8 +96,8 @@ CELERY_RESULT_BACKEND = 'djcelery.backends.cache:CacheBackend' # When the broker is behind an ELB, use a heartbeat to refresh the # connection and to detect if it has been dropped. -BROKER_HEARTBEAT = 60.0 -BROKER_HEARTBEAT_CHECKRATE = 2 +BROKER_HEARTBEAT = ENV_TOKENS.get('BROKER_HEARTBEAT', 60.0) +BROKER_HEARTBEAT_CHECKRATE = ENV_TOKENS.get('BROKER_HEARTBEAT_CHECKRATE', 2) # Each worker should only fetch one message at a time CELERYD_PREFETCH_MULTIPLIER = 1 diff --git a/lms/envs/production.py b/lms/envs/production.py index fcff4a9b0b..2aa0bd07d0 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -108,8 +108,8 @@ CELERY_RESULT_BACKEND = 'djcelery.backends.cache:CacheBackend' # When the broker is behind an ELB, use a heartbeat to refresh the # connection and to detect if it has been dropped. -BROKER_HEARTBEAT = 60.0 -BROKER_HEARTBEAT_CHECKRATE = 2 +BROKER_HEARTBEAT = ENV_TOKENS.get('BROKER_HEARTBEAT', 60.0) +BROKER_HEARTBEAT_CHECKRATE = ENV_TOKENS.get('BROKER_HEARTBEAT_CHECKRATE', 2) # Each worker should only fetch one message at a time CELERYD_PREFETCH_MULTIPLIER = 1