我希望使用免费的dyno将一个烧瓶应用程序部署到Heroku,它似乎成功构建:
remote: Git submodules detected, installing:
remote:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing requirements with pip
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 83.2M
remote: -----> Launching...
remote: Released v94
remote: https://MYAPP.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
然后在访问URL后检查Heroku日志我抛出了这个错误:
2017-10-25T22:33:09.264449+00:00 heroku[web.1]: Starting process with command `python run.py runserver`
2017-10-25T22:33:15.514250+00:00 app[web.1]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
2017-10-25T22:33:15.519730+00:00 app[web.1]: * Restarting with stat
2017-10-25T22:33:17.300082+00:00 app[web.1]: * Debugger is active!
2017-10-25T22:33:17.305442+00:00 app[web.1]: * Debugger pin code: 146-142-273
2017-10-25T22:34:09.286891+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-10-25T22:34:09.286934+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-10-25T22:34:09.469418+00:00 heroku[web.1]: Process exited with status 137
2017-10-25T22:34:09.484569+00:00 heroku[web.1]: State changed from starting to crashed
在各种帮助网站中遇到此问题的所有其他人在绑定到Heroku $PORT
时解决了他们的问题,与我的方法相同:
#!venv/bin/python
import os
from app import app
port = int(os.environ.get('PORT', 33507))
app.run(host='0.0.0.0', port=port, debug=False)
我的Procfile
:
web: python run.py runserver
难道我正在运行虚拟环境吗?也许我在83.2M的应用程序太大了?我有点被困在这里。在此先感谢您的帮助!
答案 0 :(得分:0)
尝试像这样更改您的Procfile内容:
网络:gunicorn run:app -b“ 0.0.0.0:$PORT” -w 3
其中run是主应用程序文件的名称,表示run.py
答案 1 :(得分:0)
尝试更改:
Procfile内容应为:
web: python run.py
端口号从33507到8080