mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 17:21:31 +00:00
Rework ProcessManagingEH log API
This commit is contained in:
parent
1a93dad562
commit
9723f98950
@ -46,13 +46,12 @@ class ProcessManagingEventHandler(EventHandlerBase):
|
|||||||
data = message['data']
|
data = message['data']
|
||||||
try:
|
try:
|
||||||
self.processmanager(data['command'], data['process_name'])
|
self.processmanager(data['command'], data['process_name'])
|
||||||
message['data']['log'] = self.processmanager.read_stdout(data['process_name'])
|
|
||||||
return message
|
|
||||||
except SupervisorFault as fault:
|
except SupervisorFault as fault:
|
||||||
message['data']['error'] = fault.faultString
|
message['data']['error'] = fault.faultString
|
||||||
message['data']['log'] = self.processmanager.read_stderr(data['process_name'])
|
|
||||||
return message
|
|
||||||
finally:
|
finally:
|
||||||
|
message['data']['stdout'] = self.processmanager.read_stdout(data['process_name'])
|
||||||
|
message['data']['stderr'] = self.processmanager.read_stderr(data['process_name'])
|
||||||
self.processmanager.clear_logs(data['process_name'])
|
self.processmanager.clear_logs(data['process_name'])
|
||||||
|
return message
|
||||||
except KeyError:
|
except KeyError:
|
||||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||||
|
@ -35,5 +35,8 @@ class SupervisorLogMixin(SupervisorBaseMixin):
|
|||||||
|
|
||||||
def clear_logs(self, process_name):
|
def clear_logs(self, process_name):
|
||||||
for logfile in ('stdout_logfile', 'stderr_logfile'):
|
for logfile in ('stdout_logfile', 'stderr_logfile'):
|
||||||
|
try:
|
||||||
remove(self.supervisor.getProcessInfo(process_name)[logfile])
|
remove(self.supervisor.getProcessInfo(process_name)[logfile])
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
self.supervisor.clearProcessLogs(process_name)
|
self.supervisor.clearProcessLogs(process_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user