Warm tip: This article is reproduced from serverfault.com, please click

其他-无法在Heroku上部署Flask应用程序

(其他 - Trouble to deploy flask application on heroku)

发布于 2020-11-27 17:03:37

我无法在heroku上部署我的flask应用程序,我的目录树如下所示:

├── 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或应用程序(如文件夹(我用用“瓶中运行”本地调用档案)初始化的.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中配置

Questioner
Luan Torres
Viewed
11
Aditya 2020-11-29 18:56:22

假设你 run.py是应用程序的入口点,并且已将flask实例命名为app,则Procfile应该如下所示:

web: gunicorn run:app

这是因为在Procfile中,第一个参数必须是运行网站的主文件或入口文件的名称,第二个则是flask实例本身的名称。至少与枪支和heroku的情况一样。