mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 11:01:31 +00:00
Separate log clearing from reading
This commit is contained in:
parent
44df95a434
commit
1a93dad562
@ -44,12 +44,15 @@ class ProcessManagingEventHandler(EventHandlerBase):
|
||||
def handle_event(self, message):
|
||||
try:
|
||||
data = message['data']
|
||||
self.processmanager(data['command'], data['process_name'])
|
||||
message['data']['log'] = self.processmanager.read_log_stdout(message['data']['process_name'])
|
||||
return message
|
||||
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:
|
||||
self.processmanager.clear_logs(data['process_name'])
|
||||
except KeyError:
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||
except SupervisorFault as fault:
|
||||
message['data']['error'] = fault.faultString
|
||||
message['data']['log'] = self.processmanager.read_log_stderr(message['data']['process_name'])
|
||||
return message
|
||||
|
@ -27,16 +27,11 @@ class SupervisorMixin(SupervisorBaseMixin):
|
||||
|
||||
|
||||
class SupervisorLogMixin(SupervisorBaseMixin):
|
||||
def read_log_stdout(self, process_name):
|
||||
return self._read_log_internal(self.supervisor.readProcessStdoutLog, process_name)
|
||||
def read_stdout(self, process_name):
|
||||
return self.supervisor.readProcessStdoutLog(process_name, 0, 0)
|
||||
|
||||
def read_log_stderr(self, process_name):
|
||||
return self._read_log_internal(self.supervisor.readProcessStderrLog, process_name)
|
||||
|
||||
def _read_log_internal(self, read_method, process_name):
|
||||
log = read_method(process_name, 0, 0)
|
||||
self.clear_logs(process_name)
|
||||
return log
|
||||
def read_stderr(self, process_name):
|
||||
return self.supervisor.readProcessStderrLog(process_name, 0, 0)
|
||||
|
||||
def clear_logs(self, process_name):
|
||||
for logfile in ('stdout_logfile', 'stderr_logfile'):
|
||||
|
Loading…
Reference in New Issue
Block a user