mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 18:11:56 +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']
|
||||
try:
|
||||
self.processmanager(data['command'], data['process_name'])
|
||||
message['data']['log'] = self.processmanager.read_stdout(data['process_name'])
|
||||
return message
|
||||
except SupervisorFault as fault:
|
||||
message['data']['error'] = fault.faultString
|
||||
message['data']['log'] = self.processmanager.read_stderr(data['process_name'])
|
||||
return message
|
||||
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'])
|
||||
return message
|
||||
except KeyError:
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||
|
@ -35,5 +35,8 @@ class SupervisorLogMixin(SupervisorBaseMixin):
|
||||
|
||||
def clear_logs(self, process_name):
|
||||
for logfile in ('stdout_logfile', 'stderr_logfile'):
|
||||
remove(self.supervisor.getProcessInfo(process_name)[logfile])
|
||||
try:
|
||||
remove(self.supervisor.getProcessInfo(process_name)[logfile])
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
self.supervisor.clearProcessLogs(process_name)
|
||||
|
Loading…
Reference in New Issue
Block a user