Merge branch 'processlog-rework' into chausie

This commit is contained in:
Kristóf Tóth 2019-08-15 14:40:02 +02:00
commit c753b63273
4 changed files with 25 additions and 16 deletions

View File

@ -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

View 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)

View File

@ -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):

View File

@ -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'):