diff --git a/lib/tfw/components/mixins/supervisor_mixin.py b/lib/tfw/components/mixins/supervisor_mixin.py index ab483ff..7023105 100644 --- a/lib/tfw/components/mixins/supervisor_mixin.py +++ b/lib/tfw/components/mixins/supervisor_mixin.py @@ -15,6 +15,9 @@ class SupervisorMixin: def start_process(self, 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): self.stop_process(process_name) self.start_process(process_name) diff --git a/lib/tfw/components/process_managing_event_handler.py b/lib/tfw/components/process_managing_event_handler.py index 938c5aa..45e2cdb 100644 --- a/lib/tfw/components/process_managing_event_handler.py +++ b/lib/tfw/components/process_managing_event_handler.py @@ -11,10 +11,11 @@ class ProcessManager(SupervisorMixin): def __init__(self): self.commands = {'start': self.start_process, 'stop': self.stop_process, - 'restart': self.restart_process} + 'restart': self.restart_process, + 'readlog': self.read_log} def __call__(self, command, process_name): - self.commands[command](process_name) + return self.commands[command](process_name) class ProcessManagingEventHandler(TriggerlessEventHandler): @@ -43,5 +44,6 @@ class ProcessManagingEventHandler(TriggerlessEventHandler): log.error('IGNORING MESSAGE: Invalid data_json received: {}'.format(data_json)) except SupervisorFault as fault: 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)) return data_json