【发布时间】:2020-11-27 17:03:37
【问题描述】:
我无法在 heroku 上部署我的烧瓶应用程序, 我的目录树如下所示:
├── app
│ ├── errors.py
│ ├── forms.py
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── models.py
│ ├── __pycache__
│ ├── routes.py
│ ├── static
│ ├── storage.db
│ └── templates
├── migrations
├── Procfile
├── README.md
├── requirements.txt
├── run.py
└── runtime.txt
$ cat runtime
python-3.8.5
$ cat Procfile
web: gunicorn: app:app
我对 Procfile 的配置很困惑,我应该调用 run.py(我用来在本地使用“flask run”调用的存档)还是 app(init.py 所在的文件夹调用flask实例和sql_alchemy实例)?
不管怎样,两种配置都返回了下面的错误:
$ heroku 日志 --tail
heroku[web.1]: State changed from crashed to starting
heroku[web.1]: Starting process with command `gunicorn: app:app`
app[web.1]: bash: gunicorn:: command not found
heroku[web.1]: Process exited with status 127
heroku[web.1]: State changed from starting to crashed
gunicorn 已经在 requirements.py 中配置了
【问题讨论】:
-
假设您的
run.py是您的应用程序的入口点,并且您已将烧瓶实例命名为app,您的 Procfile 应类似于web: gunicorn run:app -
谢谢@Aditya,它成功了!你为什么不在下面回答而不是评论?然后我会标记为最佳答案,它应该可以帮助其他人:)
-
不客气:)。老实说,我不知道为什么我没有写它作为答案?????但无论如何,我现在写它作为答案,以便其他人也可以从中受益。
标签: flask heroku deployment gunicorn