From 32bf9cadb54376f68e28c9b0a90171bd7a54b75c Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Thu, 11 Feb 2021 10:08:38 +0100 Subject: [PATCH] TMSS-614: Warn if we cannot connect to RabbitMQ. This helps understand a later error as the code retries with port -1. --- LCS/Messaging/python/messaging/config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LCS/Messaging/python/messaging/config.py b/LCS/Messaging/python/messaging/config.py index c8ea8f0763e..7373d04e907 100644 --- a/LCS/Messaging/python/messaging/config.py +++ b/LCS/Messaging/python/messaging/config.py @@ -5,6 +5,8 @@ logger = logging.getLogger(__name__) import kombu # make default kombu/amqp logger less spammy logging.getLogger("amqp").setLevel(logging.INFO) +# we're logging when this file is loaded, so format must be correct +logging.basicConfig(format = '%(asctime)s %(levelname)s %(message)s', level = logging.INFO) from lofar.messaging import adaptNameToEnvironment from lofar.common import isProductionEnvironment, isTestEnvironment @@ -59,6 +61,8 @@ for port in possible_ports: except Exception as e: logger.debug("cannot connect to broker: hostname=%s port=%s userid=%s password=*** error=%s", DEFAULT_BROKER, port, DEFAULT_USER, e) +else: + logger.error("Cannot connect to rabbitmq broker with hostname=%s userid=%s password=***. I tried ports %s.", DEFAULT_BROKER, DEFAULT_USER, possible_ports) # default exchange to use for publishing messages DEFAULT_BUSNAME = adaptNameToEnvironment(os.environ.get('LOFAR_DEFAULT_EXCHANGE', 'lofar')) -- GitLab