diff --git a/awx/main/utils/redis.py b/awx/main/utils/redis.py new file mode 100644 index 000000000000..34f0aed6c11d --- /dev/null +++ b/awx/main/utils/redis.py @@ -0,0 +1,19 @@ +import sys +import time + +from django.conf import settings + +import redis + + +def ping_redis(): + redis.Redis.from_url(settings.BROKER_URL).ping() + + +def exit_if_redis_down(logger): + try: + ping_redis() + except redis.ConnectionError as exc: + logger.info(f'Redis ping error: {exc}') + time.sleep(1) # Patience to avoid log spam + sys.exit(1)