Implement stderr feedback on deployment failure (ProcessManagingEventHandler)

This commit is contained in:
Kristóf Tóth 2018-03-08 16:04:35 +01:00
parent cb3d7b0e04
commit f874deff6e
2 changed files with 7 additions and 2 deletions

View File

@ -15,6 +15,9 @@ class SupervisorMixin:
def start_process(self, process_name): def start_process(self, process_name):
self.supervisor.startProcess(process_name) self.supervisor.startProcess(process_name)
def read_log(self, process_name):
return self.supervisor.readProcessStderrLog(process_name, 0, 0)
def restart_process(self, process_name): def restart_process(self, process_name):
self.stop_process(process_name) self.stop_process(process_name)
self.start_process(process_name) self.start_process(process_name)

View File

@ -11,10 +11,11 @@ class ProcessManager(SupervisorMixin):
def __init__(self): def __init__(self):
self.commands = {'start': self.start_process, self.commands = {'start': self.start_process,
'stop': self.stop_process, 'stop': self.stop_process,
'restart': self.restart_process} 'restart': self.restart_process,
'readlog': self.read_log}
def __call__(self, command, process_name): def __call__(self, command, process_name):
self.commands[command](process_name) return self.commands[command](process_name)
class ProcessManagingEventHandler(TriggerlessEventHandler): class ProcessManagingEventHandler(TriggerlessEventHandler):
@ -43,5 +44,6 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json)) log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json))
except SupervisorFault as fault: except SupervisorFault as fault:
data_json['data']['error'] = fault.faultString data_json['data']['error'] = fault.faultString
data_json['data']['log'] = self.processmanager.read_log(data_json['data']['process_name'])
log.debug('Failed to execute command on process: {}'.format(data_json)) log.debug('Failed to execute command on process: {}'.format(data_json))
return data_json return data_json