From b0db2b7bec074eb72aa94e2bfe52678b9f443f33 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 9 Apr 2020 13:58:48 -0400 Subject: [PATCH] add some exception handling for dealing with logging connection resets when rsyslogd restarts due to config changes, there's a brief moment where the socket will refuse connections on teardown; exception handling is needed here to deal with that --- awx/main/utils/handlers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/awx/main/utils/handlers.py b/awx/main/utils/handlers.py index ebf299a9f0..ae0e83a9c5 100644 --- a/awx/main/utils/handlers.py +++ b/awx/main/utils/handlers.py @@ -18,7 +18,14 @@ class RSysLogHandler(logging.handlers.SysLogHandler): return if not os.path.exists(settings.LOGGING['handlers']['external_logger']['address']): return - return super(RSysLogHandler, self).emit(msg) + try: + return super(RSysLogHandler, self).emit(msg) + except ConnectionRefusedError: + # rsyslogd has gone to lunch; this generally means that it's just + # been restarted (due to a configuration change) + # unfortunately, we can't log that because...rsyslogd is down (and + # would just us back ddown this code path) + pass ColorHandler = logging.StreamHandler