mirror of
https://github.com/ansible/awx.git
synced 2026-06-21 22:57:48 -02:30
* WIP First pass * started removing feature flags and adjusting logic * Add decorator * moved to dispatcher decorator * updated as many as I could find * Keep callback receiver working * remove any code that is not used by the call back receiver * add back auto_max_workers * added back get_auto_max_workers into common utils * Remove control and hazmat (squash this not done) * moved status out and deleted control as no longer needed * removed unused imports * adjusted test import to pull correct method * fixed imports and addressed clusternode heartbeat test * Update function comments * Add back hazmat for config and remove baseworker * added back hazmat per @alancoding feedback around config * removed baseworker completely and refactored it into the callback worker * Fix dispatcher run call and remove dispatch setting * remove dispatcher mock publish setting * Adjust heartbeat arg and more formatting * fixed the call to cluster_node_heartbeat missing binder * Fix attribute error in server logs
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import logging
|
|
import json
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from awx.main.dispatch import pg_bus_conn
|
|
from awx.main.dispatch.worker.task import run_callable
|
|
|
|
logger = logging.getLogger('awx.main.cache_clear')
|
|
|
|
|
|
class Command(BaseCommand):
|
|
"""
|
|
Cache Clear
|
|
Runs as a management command and starts a daemon that listens for a pg_notify message to clear the cache.
|
|
"""
|
|
|
|
help = 'Launch the cache clear daemon'
|
|
|
|
def handle(self, *arg, **options):
|
|
try:
|
|
with pg_bus_conn() as conn:
|
|
conn.listen("tower_settings_change")
|
|
for e in conn.events():
|
|
if e is not None:
|
|
body = json.loads(e.payload)
|
|
logger.info(f"Cache clear request received. Clearing now, payload: {e.payload}")
|
|
run_callable(body)
|
|
|
|
except Exception:
|
|
# Log unanticipated exception in addition to writing to stderr to get timestamps and other metadata
|
|
logger.exception('Encountered unhandled error in cache clear main loop')
|
|
raise
|