Commit b91e4e41 authored by wanli's avatar wanli

update

parent a841cc68
...@@ -23,26 +23,26 @@ def run(): ...@@ -23,26 +23,26 @@ def run():
生产模式启动命令函数 生产模式启动命令函数
To use: python3 manager.py run To use: python3 manager.py run
""" """
app.logger.setLevel(app.config.get('LOG_LEVEL', logging.INFO)) # app.logger.setLevel(app.config.get('LOG_LEVEL', logging.INFO))
service_config = { # service_config = {
'bind': app.config.get('BIND', '0.0.0.0:3000'), # 'bind': app.config.get('BIND', '0.0.0.0:3000'),
'workers': app.config.get('WORKERS', cpu_count() * 2 + 1), # 'workers': app.config.get('WORKERS', cpu_count() * 2 + 1),
'worker_class': 'gevent', # 'worker_class': 'gevent',
'worker_connections': app.config.get('WORKER_CONNECTIONS', 10000), # 'worker_connections': app.config.get('WORKER_CONNECTIONS', 10000),
'backlog': app.config.get('BACKLOG', 2048), # 'backlog': app.config.get('BACKLOG', 2048),
'timeout': app.config.get('TIMEOUT', 60), # 'timeout': app.config.get('TIMEOUT', 60),
'loglevel': app.config.get('LOG_LEVEL', 'info'), # 'loglevel': app.config.get('LOG_LEVEL', 'info'),
'pidfile': app.config.get('PID_FILE', 'run.pid'), # 'pidfile': app.config.get('PID_FILE', 'run.pid'),
} # }
http_server = HTTPServer(WSGIContainer(app)) http_server = HTTPServer(WSGIContainer(app))
http_server.listen(3000) http_server.listen(3000, address='127.0.0.1')
# wsgi_app = WSGIContainer(app) # wsgi_app = WSGIContainer(app)
# application = Application([ # application = Application([
# (r'.*', FallbackHandler, dict(fallback=wsgi_app)) # (r'.*', FallbackHandler, dict(fallback=wsgi_app))
# ], **service_config) # ], **service_config)
# application.listen(3000, address='127.0.0.1') # application.listen(3000)
IOLoop.instance().start() IOLoop.instance().start()
......
...@@ -28,12 +28,12 @@ def pushmessage(func): ...@@ -28,12 +28,12 @@ def pushmessage(func):
try: try:
if isinstance(msg, WebsocketResponse) or isinstance(msg, dict): if isinstance(msg, WebsocketResponse) or isinstance(msg, dict):
self.write_message(json.dumps(msg), binary) self.write_message(json.dumps(msg), binary)
elif isinstance(msg, str) or isinstance(msg, unicode): elif isinstance(msg, str) or isinstance(msg, str):
self.write_message(msg, binary) self.write_message(msg, binary)
else: else:
self.write_message(repr(msg), binary) self.write_message(repr(msg), binary)
except WebSocketClosedError as e: except WebSocketClosedError as e:
logger.error(e)
self.on_close() self.on_close()
return send return send
......
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