Skip to content

Commit

Permalink
Consistent behavior with dispatcher and callback
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Aug 28, 2024
1 parent 6d3b3d9 commit 3af35db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 5 additions & 4 deletions awx/main/management/commands/run_callback_receiver.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright (c) 2015 Ansible, Inc.
# All Rights Reserved.

import redis

from django.conf import settings
from django.core.management.base import BaseCommand, CommandError

from redis.exceptions import ConnectionError
import redis.exceptions

from awx.main.analytics.subsystem_metrics import CallbackReceiverMetricsServer
from awx.main.dispatch.control import Control
Expand All @@ -31,8 +32,8 @@ def handle(self, *arg, **options):

try:
CallbackReceiverMetricsServer().start()
except ConnectionError as exc:
raise CommandError(f'Could not connect to redis, error:\n{exc}\n')
except redis.exceptions.ConnectionError as exc:
raise CommandError(f'Callback receiver could not connect to redis, error: {exc}')

try:
consumer = AWXConsumerRedis(
Expand Down
9 changes: 7 additions & 2 deletions awx/main/management/commands/run_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import logging
import yaml

import redis

from django.conf import settings
from django.core.management.base import BaseCommand
from django.core.management.base import BaseCommand, CommandError

from awx.main.dispatch import get_task_queuename
from awx.main.dispatch.control import Control
Expand Down Expand Up @@ -63,7 +65,10 @@ def handle(self, *arg, **options):

consumer = None

DispatcherMetricsServer().start()
try:
DispatcherMetricsServer().start()
except redis.exceptions.ConnectionError as exc:
raise CommandError(f'Dispatcher could not connect to redis, error: {exc}')

try:
queues = ['tower_broadcast_all', 'tower_settings_change', get_task_queuename()]
Expand Down

0 comments on commit 3af35db

Please sign in to comment.