Commit 7bfaf0b0 authored by ibuler's avatar ibuler

[Update] Merge

parents 7ce5483d e4da494d
......@@ -9,6 +9,8 @@ import threading
import socket
import json
import signal
import eventlet
from eventlet.debug import hub_prevent_multiple_readers
from jms.service import AppService
......@@ -20,8 +22,10 @@ from .tasks import TaskHandler
from .recorder import ReplayRecorder, CommandRecorder
from .utils import get_logger, register_app, register_service
eventlet.monkey_patch()
hub_prevent_multiple_readers(False)
__version__ = '1.3.0'
__version__ = '1.3.1'
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
logger = get_logger(__file__)
......
......@@ -4,7 +4,6 @@
import os
import socket
import uuid
import eventlet
from flask_socketio import SocketIO, Namespace, join_room
from flask import Flask, request, current_app, redirect
......@@ -14,11 +13,8 @@ from .utils import get_logger
from .ctx import current_app, app_service
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
logger = get_logger(__file__)
eventlet.monkey_patch()
class BaseNamespace(Namespace):
current_user = None
......@@ -172,7 +168,7 @@ class ProxyNamespace(BaseNamespace):
room = self.new_room()
self.emit('room', {'room': room["id"], 'secret': secret})
if not token or not secret:
logger.debug("Token or secret is None")
logger.debug("Token or secret is None: {}".format(token, secret))
self.emit('data', {'data': "\nOperation not permitted!",
'room': room["id"]})
self.emit('disconnect')
......@@ -230,6 +226,9 @@ class ProxyNamespace(BaseNamespace):
del self.connections[request.sid][room_id]
del room
def on_ping(self):
self.emit('pong')
class HttpServer:
# prepare may be rewrite it
......@@ -241,8 +240,10 @@ class HttpServer:
init_kwargs = dict(
async_mode="eventlet",
# async_mode="threading",
ping_timeout=20,
ping_interval=10
# ping_timeout=20,
# ping_interval=10,
# engineio_logger=True,
# logger=True
)
def __init__(self):
......@@ -267,7 +268,7 @@ class HttpServer:
def run(self):
host = self.flask_app.config["BIND_HOST"]
port = self.flask_app.config["HTTPD_PORT"]
print('Starting websock server at {}:{}'.format(host, port))
print('Starting websocket server at {}:{}'.format(host, port))
self.socket_io.init_app(
self.flask_app,
**self.init_kwargs
......@@ -275,4 +276,5 @@ class HttpServer:
self.socket_io.run(self.flask_app, port=port, host=host, debug=False)
def shutdown(self):
self.socket_io.server.close()
self.socket_io.stop()
pass
......@@ -49,6 +49,8 @@ def create_logger(app):
'coco': main_setting,
'paramiko': main_setting,
'jms': main_setting,
# 'socket.io': main_setting,
# 'engineio': main_setting,
}
)
......
......@@ -9,9 +9,7 @@ logger = get_logger(__file__)
class TaskHandler:
routes = None
def init(self):
def __init__(self):
self.routes = {
'kill_session': self.handle_kill_session
}
......
......@@ -12,7 +12,7 @@ cryptography==2.1.4
docutils==0.14
dotmap==1.2.20
elasticsearch==6.1.1
Flask==0.12.2
Flask==1.0.2
Flask-SocketIO==2.9.2
idna==2.6
itsdangerous==0.24
......@@ -40,5 +40,5 @@ six==1.11.0
tornado==4.5.2
urllib3==1.22
wcwidth==0.1.7
Werkzeug==0.12.2
eventlet==0.22.1
Werkzeug==0.14.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment