mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 12:51:32 +00:00
Merge branch 'processlog-rework' into chausie
This commit is contained in:
commit
c753b63273
@ -1,2 +1,3 @@
|
||||
from .frontend_handler import FrontendHandler
|
||||
from .frontend_proxy_handler import FrontendProxyHandler
|
||||
from .console_logs_handler import ConsoleLogsHandler
|
||||
from .message_sender import MessageSender
|
||||
|
19
tfw/components/frontend/console_logs_handler.py
Normal file
19
tfw/components/frontend/console_logs_handler.py
Normal file
@ -0,0 +1,19 @@
|
||||
import logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConsoleLogsHandler:
|
||||
keys = ['process.log.new']
|
||||
|
||||
def __init__(self, *, stream):
|
||||
self.stream = stream
|
||||
|
||||
def handle_event(self, message, connector):
|
||||
try:
|
||||
connector.send_message({
|
||||
'key': 'console.write',
|
||||
'value': message[self.stream]
|
||||
})
|
||||
except KeyError:
|
||||
LOG.error('Invalid %s message received: %s', self.keys, message)
|
@ -3,7 +3,7 @@ from tfw.internals.networking import Scope
|
||||
from .message_storage import FrontendMessageStorage
|
||||
|
||||
|
||||
class FrontendHandler:
|
||||
class FrontendProxyHandler:
|
||||
keys = ['console', 'dashboard', 'message', 'ide.read', 'recover']
|
||||
|
||||
def __init__(self):
|
@ -3,18 +3,16 @@ from xmlrpc.client import Fault as SupervisorFault
|
||||
|
||||
from tfw.internals.networking import Scope
|
||||
|
||||
from .supervisor import ProcessManager, ProcessLogManager
|
||||
from .supervisor import ProcessManager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ProcessHandler(ProcessManager, ProcessLogManager):
|
||||
class ProcessHandler(ProcessManager):
|
||||
keys = ['process']
|
||||
|
||||
def __init__(self, *, supervisor_uri, log_tail=0):
|
||||
def __init__(self, *, supervisor_uri):
|
||||
ProcessManager.__init__(self, supervisor_uri)
|
||||
ProcessLogManager.__init__(self, supervisor_uri)
|
||||
self.log_tail = log_tail
|
||||
|
||||
self.commands = {
|
||||
'process.start': self.start_process,
|
||||
@ -28,15 +26,6 @@ class ProcessHandler(ProcessManager, ProcessLogManager):
|
||||
self.commands[message['key']](message['name'])
|
||||
except SupervisorFault as fault:
|
||||
message['error'] = fault.faultString
|
||||
finally:
|
||||
message['stdout'] = self.read_stdout(
|
||||
message['name'],
|
||||
self.log_tail
|
||||
)
|
||||
message['stderr'] = self.read_stderr(
|
||||
message['name'],
|
||||
self.log_tail
|
||||
)
|
||||
connector.send_message(message, scope=Scope.WEBSOCKET)
|
||||
except KeyError:
|
||||
if not message['key'].startswith('process.log'):
|
||||
|
Loading…
Reference in New Issue
Block a user