【问题标题】:failed to find application 'wsgi' when launching upstart script启动新贵脚本时找不到应用程序“wsgi”
【发布时间】:2016-05-29 18:57:30
【问题描述】:

我正在尝试将使用 Flask 编写的 Web 应用程序部署到基于 Ubuntu 的 VPS(托管在 Digital Ocean 上)上。我在部署的最后步骤中遇到了问题。

this guide 之后,我已经完成了所有项目,直到项目完全失败的 Upstart 脚本。

sudo start myproject 之后查看日志文件,我发现一行内容为:Failed to find application 'wsgi'

文件夹结构:

myproject
- venv
- templates
- static
- wsgi.py
- main.py

wsgi.py 是:

from main import app

if __name__ == "__main__":
    app.run()

最后,Upstart 文件目前是:

start on runlevel [2345]
stop on runlevel [!2345]

respawn
setuid myuseraccount
setgid www-data

env PATH=/var/www/myproject/venv/bin
chdir /var/www/myproject

exec gunicorn --workers 2 --bind unix:myproject.sock -m 007 wsgi:app

我花了很多时间试图排除故障,但我迷路了。当我在虚拟环境中使用gunicorn --bind 0.0.0.0:8000 wsgi:app 启动项目时,一切正常。

以防万一,nginx配置:

server {
    listen 80;
    server_name myproject.com www.myproject.com;

    location / {
        include proxy_params;
        proxy_pass http://unix:/var/www/myproject/myproject.sock;
    }

【问题讨论】:

    标签: python nginx flask gunicorn upstart


    【解决方案1】:

    我也遇到了同样的问题。还有另一个问题的答案应该对您有所帮助,因为它确实对我有所帮助:Gunicorn can't find app when name changed from "application"

    【讨论】:

      猜你喜欢
      • 2012-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-23
      • 2016-05-27
      • 1970-01-01
      • 1970-01-01
      • 2017-09-09
      相关资源
      最近更新 更多