运行Flask + Gunicorn + SocketIO

时间:2013-03-16 20:31:21

标签: python flask gunicorn gevent-socketio

我正在为我的烧瓶应用运行SocketIOServer,我有一个run.py脚本,如下所示:

import sys
from idateproto import create_app, run_app

if __name__ == "__main__":
    if len(sys.argv) > 1:
        create_app(sys.argv[1])
    else:
        create_app('dev')
    run_app()

和run_app看起来像这样:

def run_app():
    # Run the application
    # See flask/app.py run() for the implementation of run().
    # See http://werkzeug.pocoo.org/docs/serving/ for the parameters of Werkzeug's run_simple()
    # If the debug parameter is not set, Flask does not change app.debug, which is set from
    # the DEBUG app config variable, which we've set in create_app().
    #app.run(**app_run_args)
    global app
    global middleware
    SocketIOServer((app.config['HOST'], app.conf`enter code here`ig['PORT']), middleware,namespace="socket.io", policy_server=False).serve_forever()

我运行它:python run.py production / dev / test等。

现在我想使用gunicorn在生产中运行它,所有在线教程建议做类似的事情:     gunicorn run:app -c gunicorn-config.py 我的问题是我不想再运行我的应用了。我想告诉gunicorn在SocketIOServer上运行serve_forever方法,我在网上做了很多研究,但找不到实现这个目标的方法。请帮忙。

0 个答案:

没有答案
相关问题