mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 23:51:32 +00:00
Fix terminado buffer issues & terminado server OO refactor
This commit is contained in:
parent
8244e22479
commit
96b5234fc1
@ -1,7 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
from shutil import rmtree, copytree
|
from shutil import rmtree, copytree
|
||||||
from xmlrpc.client import Fault as SupervisorFault
|
|
||||||
from contextlib import suppress
|
|
||||||
|
|
||||||
from event_handler_base import EventHandlerBase
|
from event_handler_base import EventHandlerBase
|
||||||
from util import SupervisorMixin
|
from util import SupervisorMixin
|
||||||
@ -23,8 +21,3 @@ class TerminadoEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
def handle_event(self, anchor, data_json):
|
def handle_event(self, anchor, data_json):
|
||||||
logging.debug('TerminadoEventHandler received event for anchor {}'.format(anchor))
|
logging.debug('TerminadoEventHandler received event for anchor {}'.format(anchor))
|
||||||
# TODO: wat do?
|
# TODO: wat do?
|
||||||
|
|
||||||
def handle_reset(self, data_json):
|
|
||||||
with suppress(SupervisorFault):
|
|
||||||
self.supervisor.stopProcess(self.process_name)
|
|
||||||
self.supervisor.startProcess(self.process_name)
|
|
||||||
|
@ -1,25 +1,33 @@
|
|||||||
import logging
|
import logging
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
from tornado.web import Application
|
from tornado.web import Application
|
||||||
from terminado import TermSocket, SingleTermManager
|
from terminado import TermSocket, UniqueTermManager
|
||||||
|
|
||||||
from config import TERMINADO_PORT, TERMINADO_WD
|
from config import TERMINADO_PORT, TERMINADO_WD
|
||||||
|
|
||||||
|
|
||||||
class CORSTermSocket(TermSocket):
|
class TerminadoMiniServer:
|
||||||
def check_origin(self, origin):
|
def __init__(self, url, port, workdir, shellcmd):
|
||||||
return True
|
self.port = port
|
||||||
|
self.application = Application(
|
||||||
|
[(
|
||||||
|
url,
|
||||||
|
TerminadoMiniServer.CORSTermSocket,
|
||||||
|
{'term_manager': UniqueTermManager(shell_command=shellcmd,
|
||||||
|
term_settings={'cwd': workdir})}
|
||||||
|
)]
|
||||||
|
)
|
||||||
|
|
||||||
|
class CORSTermSocket(TermSocket):
|
||||||
|
def check_origin(self, origin):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def listen(self):
|
||||||
|
self.application.listen(self.port)
|
||||||
|
IOLoop.instance().start()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
application = Application(
|
|
||||||
[(
|
|
||||||
r'/terminal',
|
|
||||||
CORSTermSocket,
|
|
||||||
{'term_manager': SingleTermManager(shell_command=['bash'],
|
|
||||||
term_settings={'cwd': TERMINADO_WD})}
|
|
||||||
)]
|
|
||||||
)
|
|
||||||
application.listen(TERMINADO_PORT)
|
|
||||||
logging.getLogger().setLevel(logging.DEBUG)
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
logging.info('Terminado Mini Server listening on {}'.format(TERMINADO_PORT))
|
logging.info('Terminado Mini Server listening on {}'.format(TERMINADO_PORT))
|
||||||
IOLoop.instance().start()
|
TerminadoMiniServer('/terminal', TERMINADO_PORT, TERMINADO_WD, ['bash']).listen()
|
||||||
|
Loading…
Reference in New Issue
Block a user