nice error message when redis is down

* awx_manage run_wsbroadcast --status nice error message if someone
failed to start awx services (i.e. redis)
This commit is contained in:
chris meyers
2020-04-15 13:28:13 -04:00
parent 63f56d33aa
commit 1acca459ef

View File

@@ -4,6 +4,7 @@ import logging
import asyncio import asyncio
import datetime import datetime
import re import re
import redis
from datetime import datetime as dt from datetime import datetime as dt
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
@@ -91,7 +92,12 @@ class Command(BaseCommand):
def handle(self, *arg, **options): def handle(self, *arg, **options):
if options.get('status'): if options.get('status'):
stats_all = BroadcastWebsocketStatsManager.get_stats_sync() try:
stats_all = BroadcastWebsocketStatsManager.get_stats_sync()
except redis.exceptions.ConnectionError as e:
print(f"Unable to get Broadcast Websocket Status. Failed to connect to redis {e}")
return
data = {} data = {}
for family in stats_all: for family in stats_all:
if family.type == 'gauge' and len(family.samples) > 1: if family.type == 'gauge' and len(family.samples) > 1: