mirror of
https://github.com/ansible/awx.git
synced 2026-03-20 02:17:37 -02:30
Merge pull request #6017 from AlanCoding/supervisor_verbosity
Add supervisorctl logs
This commit is contained in:
@@ -3,10 +3,15 @@ from awx.main.utils import reload
|
|||||||
|
|
||||||
|
|
||||||
def test_produce_supervisor_command(mocker):
|
def test_produce_supervisor_command(mocker):
|
||||||
with mocker.patch.object(reload.subprocess, 'Popen'):
|
communicate_mock = mocker.MagicMock(return_value=('Everything is fine', ''))
|
||||||
|
mock_process = mocker.MagicMock()
|
||||||
|
mock_process.communicate = communicate_mock
|
||||||
|
Popen_mock = mocker.MagicMock(return_value=mock_process)
|
||||||
|
with mocker.patch.object(reload.subprocess, 'Popen', Popen_mock):
|
||||||
reload._supervisor_service_command(['beat', 'callback', 'fact'], "restart")
|
reload._supervisor_service_command(['beat', 'callback', 'fact'], "restart")
|
||||||
reload.subprocess.Popen.assert_called_once_with(
|
reload.subprocess.Popen.assert_called_once_with(
|
||||||
['supervisorctl', 'restart', 'tower-processes:receiver', 'tower-processes:factcacher'])
|
['supervisorctl', 'restart', 'tower-processes:receiver', 'tower-processes:factcacher'],
|
||||||
|
stderr=-1, stdin=-1, stdout=-1)
|
||||||
|
|
||||||
|
|
||||||
def test_routing_of_service_restarts_works(mocker):
|
def test_routing_of_service_restarts_works(mocker):
|
||||||
|
|||||||
@@ -49,7 +49,15 @@ def _supervisor_service_command(service_internal_names, command):
|
|||||||
args.extend([command])
|
args.extend([command])
|
||||||
args.extend(programs)
|
args.extend(programs)
|
||||||
logger.debug('Issuing command to restart services, args={}'.format(args))
|
logger.debug('Issuing command to restart services, args={}'.format(args))
|
||||||
subprocess.Popen(args)
|
supervisor_process = subprocess.Popen(args, stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
restart_stdout, restart_err = supervisor_process.communicate()
|
||||||
|
restart_code = supervisor_process.returncode
|
||||||
|
if restart_code or restart_err:
|
||||||
|
logger.error('supervisorctl restart errored with exit code `{}`, stdout:\n{}stderr:\n{}'.format(
|
||||||
|
restart_code, restart_stdout.strip(), restart_err.strip()))
|
||||||
|
else:
|
||||||
|
logger.info('supervisorctl restart finished, stdout:\n{}'.format(restart_stdout.strip()))
|
||||||
|
|
||||||
|
|
||||||
def restart_local_services(service_internal_names):
|
def restart_local_services(service_internal_names):
|
||||||
|
|||||||
Reference in New Issue
Block a user