当尝试通过uwsg运行flask应用程序时无法从uwsgi加载配置

问题描述 投票:0回答:1

我有以下uwsgi app.ini文件:

[uwsgi]
wsgi-file = wsgi.py
callable = app
socket = :5000
processes = 5
threads = 2
master = true
chmod-socket = 660
vacuum = true
die-on-term = true

wsgi.py内容:

from app import start

start()

最后是app.py,它是Flask应用程序本身(相当长,所以我只列出相关内容:]]

# instantiate the app
app = Flask(__name__, static_url_path='', static_folder='static', template_folder='templates')
app.config.from_object(__name__)

# enable CORS
CORS(app, resources={r'/*': {'origins': '*'}})


@app.route('/')
def index():
    return render_template('index.html')


... all sort of methods here ...


def start():
    print("STARTING !!!")
    app.run(host='0.0.0.0')


if __name__ == '__main__':
    start()

所有文件都在同一文件夹中。当我运行uwsgi app.ini时,我得到了:

 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
unable to load configuration from uwsgi

这是为什么?

感谢您的帮助

我有以下uwsgi app.ini文件:[uwsgi] wsgi-file = wsgi.py可调用=应用套接字=:5000进程= 5线程= 2主=真正的chmod-socket = 660真空=真正的消亡-term = true wsgi.py ...

python flask uwsgi
1个回答
1
投票

快速浏览显示了两个问题。首先,uwsgiapp.run()不兼容。在使用Flask开发环境时,可以使用后者。 uwsgi想要保存Flask实例的对象。按照惯例,尽管您可以使用其他名称(并配置app来查找其他名称),但是该名称为uwsgi

© www.soinside.com 2019 - 2024. All rights reserved.