mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-23 00:01:31 +00:00
Implement stderr feedback on deployment failure (ProcessManagingEventHandler)
This commit is contained in:
parent
cb3d7b0e04
commit
f874deff6e
@ -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)
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user