【问题标题】:Setting Flask-SockerIO to run in Gunicorn Server将 Flask-SockerIO 设置为在 Gunicorn Server 中运行
【发布时间】:2014-01-12 23:11:04
【问题描述】:

我尝试在 Ubuntu OS 中运行 SocketIO 服务器以在 Gunicorn 中运行。

gevent
gevent-socketio
独角兽

运行.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.

【问题讨论】:

    标签: flask gevent gunicorn socket.io gevent-socketio


    【解决方案1】:

    您可以评论这一行 @werkzeug.serving.run_with_reloader,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-04
      • 2019-10-04
      • 2021-06-24
      • 1970-01-01
      • 2016-05-06
      • 1970-01-01
      • 2017-12-02
      • 1970-01-01
      相关资源
      最近更新 更多