我尝试在 Ubuntu OS 中运行 SocketIO 服务器以在 Gunicorn 中运行。
gevent
gevent-socketio
gunicorn
运行.py
from views import app
from gevent import monkey
from socketio.server import SocketIOServer
import werkzeug.serving
monkey.patch_all()
PORT = 5000
@werkzeug.serving.run_with_reloader
def runServer()
print 'Listening on http://127.0.0.1:%s and on port 10843 (flash policy server)' % PORT
SocketIOServer(('', PORT), app, resource="socket.io").serve_forever()
if __name__ == '__main__':
runServer()
使用的命令 -
gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker run:app
连接似乎经常被丢弃和重新连接日志 -
2013-12-24 22:40:59 [3331] [INFO] Starting gunicorn 0.13.4
2013-12-24 22:40:59 [3331] [INFO] Listening at: http://127.0.0.1:8000 (3331)
2013-12-24 22:40:59 [3331] [INFO] Using worker: socketio.sgunicorn.GeventSocketIOWorker
2013-12-24 22:40:59 [3334] [INFO] Booting worker with pid: 3334
2013-12-24 22:41:01 [3339] [INFO] Starting gunicorn 0.13.4
2013-12-24 22:41:01 [3339] [ERROR] Connection in use: ('127.0.0.1', 8000)
2013-12-24 22:41:01 [3339] [ERROR] Retrying in 1 second.
2013-12-24 22:41:02 [3339] [ERROR] Connection in use: ('127.0.0.1', 8000)
2013-12-24 22:41:02 [3339] [ERROR] Retrying in 1 second.
2013-12-24 22:41:03 [3339] [ERROR] Connection in use: ('127.0.0.1', 8000)
2013-12-24 22:41:03 [3339] [ERROR] Retrying in 1 second.
2013-12-24 22:41:04 [3339] [ERROR] Connection in use: ('127.0.0.1', 8000)
2013-12-24 22:41:04 [3339] [ERROR] Retrying in 1 second.