mirror of
https://github.com/ansible/awx.git
synced 2026-08-03 11:30:00 -02:30
AWX code changes for rsyslog decoupling (#13222)
* add management command and logging for new daemon * switch tasks over to calling pg_notify * add daemon to docker-compose and supervisor * renamed handle_setting_changes and moved notify call * removed initial rsyslog configure from dispatcher * add logging and clear cache before reconfigure * add notify to delete * moved pg_notify to own function * update tests impacted by rsyslog change * changed over to new pg_notify method Signed-off-by: Jessica Mack <jmack@redhat.com>
This commit is contained in:
38
awx/main/management/commands/run_rsyslog_configurer.py
Normal file
38
awx/main/management/commands/run_rsyslog_configurer.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import logging
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from awx.main.dispatch import pg_bus_conn
|
||||
from awx.main.utils.external_logging import reconfigure_rsyslog
|
||||
|
||||
logger = logging.getLogger('awx.main.rsyslog_configurer')
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
Rsyslog Configurer
|
||||
Runs as a management command and starts rsyslog configurer daemon. Daemon listens
|
||||
for pg_notify then calls reconfigure_rsyslog
|
||||
"""
|
||||
|
||||
help = 'Launch the rsyslog_configurer daemon'
|
||||
|
||||
def handle(self, *arg, **options):
|
||||
try:
|
||||
with pg_bus_conn(new_connection=True) as conn:
|
||||
conn.listen("rsyslog_configurer")
|
||||
# reconfigure rsyslog on start up
|
||||
reconfigure_rsyslog()
|
||||
for e in conn.events(yield_timeouts=True):
|
||||
if e is not None:
|
||||
logger.info("Change in logging settings found. Restarting rsyslogd")
|
||||
# clear the cache of relevant settings then restart
|
||||
setting_keys = [k for k in dir(settings) if k.startswith('LOG_AGGREGATOR')]
|
||||
cache.delete_many(setting_keys)
|
||||
settings._awx_conf_memoizedcache.clear()
|
||||
reconfigure_rsyslog()
|
||||
except Exception:
|
||||
# Log unanticipated exception in addition to writing to stderr to get timestamps and other metadata
|
||||
logger.exception('Encountered unhandled error in rsyslog_configurer main loop')
|
||||
raise
|
||||
Reference in New Issue
Block a user