Extend ProcessManagingEventHander with deployment failure detection

This commit is contained in:
Kristóf Tóth 2018-03-07 15:14:33 +01:00
parent d11d9a70cb
commit 9b550f724d

View File

@ -1,4 +1,5 @@
from functools import wraps
from xmlrpc.client import Fault as SupervisorFault
from tfw.event_handler_base import TriggerlessEventHandler
from tfw.components.mixins import SupervisorMixin
@ -37,6 +38,11 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
try:
data = data_json['data']
self.processmanager(data['command'], data['process_name'])
data_json['data']['error'] = False
return data_json
except KeyError:
log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json))
except SupervisorFault:
data_json['data']['error'] = True
log.debug('Failed to execute command on process: {}'.format(data_json))
return data_json