【问题标题】:Python/Django crash on gunicorn on HerokuPython/Django 在 Heroku 上的 gunicorn 上崩溃
【发布时间】:2017-04-25 12:11:51
【问题描述】:

我已将我的应用部署到 Heroku,并在加载页面时在日志中收到以下错误:

2016-12-09T22:47:56.020392+00:00 heroku[slug-compiler]: Slug compilation started
2016-12-09T22:47:56.020401+00:00 heroku[slug-compiler]: Slug compilation finished
2016-12-09T22:47:56.001478+00:00 heroku[web.1]: State changed from crashed to starting
2016-12-09T22:48:00.770182+00:00 heroku[web.1]: Starting process with command `gunicorn surfspots.wsgi --log-file -`
2016-12-09T22:48:03.282956+00:00 heroku[web.1]: Process exited with status 127
2016-12-09T22:48:03.180446+00:00 app[web.1]: bash: gunicorn: command not found
2016-12-09T22:48:03.300446+00:00 heroku[web.1]: State changed from starting to crashed

我正在运行 Python 3.5.2:

$ cat runtime.txt 
python-3.5.2

我的 Django 项目的名称是“surfspots”:

$ cat Procfile 
web: gunicorn surfspots.wsgi --log-file -

对于this person,他们收到了同样的问题并解决了,因为他们没有安装gunicorn。

但是,我确实在我的 requirements.txt 中安装了 gunicorn,使用“pip install gunicorn”

这是我的 requirements.txt 文件:

$ cat requirements.txt
boto==2.43.0
click==6.6
click-plugins==1.0.3
cligj==0.4.0
descartes==1.0.2
dj-database-url==0.4.1
Django==1.10.4
django-bootstrap3==7.1.0
django-geojson==2.9.1
django-leaflet==0.19.0
django-storages==1.5.1
django-tables2==1.2.6
django-widget-tweaks==1.4.1
Fiona==1.7.1
GeoAlchemy2==0.4.0
gunicorn==19.6.0
jsonfield==1.0.3
munch==2.0.4
numpy==1.11.2
pandas==0.19.1
psycopg2==2.6.2
pyproj==1.9.5.1
python-dateutil==2.6.0
pytz==2016.7
requests==2.12.3
six==1.10.0
SQLAlchemy==1.1.4

这是我的 Django 项目的目录结构:

$ tree . -L 2
.
├── locations
│   ├── admin.py
│   ├── apps.py
│   ├── data
│   ├── __init__.py
│   ├── migrations
│   ├── models.py
│   ├── __pycache__
│   ├── static
│   ├── templates
│   ├── tests.py
│   └── views.py
├── manage.py
├── Procfile
├── README.md
├── requirements.txt
├── runtime.txt
├── surfspots
│   ├── __init__.py
│   ├── __pycache__
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── venv
    ├── bin
    ├── include
    ├── lib
    └── pip-selfcheck.json

有什么建议吗?谢谢!

【问题讨论】:

  • runtime.txt文件中指定了哪个python版本?
  • gunicon 是为您的用户安装的,还是为整个系统安装的?从 bash 返回代码 127 意味着它找不到该可执行文件的路径 - 确保它在 Heroku 用户的 PATH 中。 (有关上下文,请参见此处:stackoverflow.com/a/1763178/3276583
  • requirements.txt 是否已提交给 git?你能展示你的文件结构吗?
  • 谢谢@EugeneLisitsky!我正在运行 Python 3.5.2——将其添加到我的原始帖子中。是的,我确实在 runtime.txt 文件中指定了 Python 版本
  • 谢谢@DanielRoseman!是的,requirements.txt 文件已提交给 git。我将我的文件结构添加到我的原始帖子中。

标签: python django heroku gunicorn


【解决方案1】:

奇怪的是,我的 Heroku 版本无法访问 gunicorn。但是,我刚刚在this post 中看到了一个答案,建议我远程卸载所有需求,然后重新安装它们。这恰好对我有用!谢谢大家的及时回复,非常感谢。

【讨论】:

    猜你喜欢
    • 2018-11-01
    • 2015-03-16
    • 2012-11-26
    • 1970-01-01
    • 2012-05-18
    • 2012-03-11
    • 2014-08-29
    • 2013-08-14
    • 1970-01-01
    相关资源
    最近更新 更多