mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-24 07:31:32 +00:00
Add support for stopping/starting ProcessLogHandler from API
This commit is contained in:
parent
c8d4080ef5
commit
9481e8f921
@ -16,17 +16,20 @@ class ProcessLogHandler:
|
|||||||
self._initial_log_tail = log_tail
|
self._initial_log_tail = log_tail
|
||||||
|
|
||||||
self.command_handlers = {
|
self.command_handlers = {
|
||||||
'process.log.set': self.handle_set
|
'process.log.set': self.handle_set,
|
||||||
|
'process.log.start': self.handle_start,
|
||||||
|
'process.log.stop': self.handle_stop
|
||||||
}
|
}
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self._monitor = LogInotifyObserver(
|
if not self._monitor:
|
||||||
connector=self.connector,
|
self._monitor = LogInotifyObserver(
|
||||||
process_name=self.process_name,
|
connector=self.connector,
|
||||||
supervisor_uri=self._supervisor_uri,
|
process_name=self.process_name,
|
||||||
log_tail=self._initial_log_tail
|
supervisor_uri=self._supervisor_uri,
|
||||||
)
|
log_tail=self._initial_log_tail
|
||||||
self._monitor.start()
|
)
|
||||||
|
self._monitor.start()
|
||||||
|
|
||||||
def handle_event(self, message, _):
|
def handle_event(self, message, _):
|
||||||
try:
|
try:
|
||||||
@ -40,5 +43,16 @@ class ProcessLogHandler:
|
|||||||
if data.get('tail'):
|
if data.get('tail'):
|
||||||
self._monitor.log_tail = data['tail']
|
self._monitor.log_tail = data['tail']
|
||||||
|
|
||||||
|
def handle_start(self, _):
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
def handle_stop(self, _):
|
||||||
|
self._stop_monitor()
|
||||||
|
|
||||||
|
def _stop_monitor(self):
|
||||||
|
if self._monitor:
|
||||||
|
self._monitor.stop()
|
||||||
|
self._monitor = None
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
self._monitor.stop()
|
self._stop_monitor()
|
||||||
|
Loading…
Reference in New Issue
Block a user