Sha*_*unK 4 python heroku flask
我的应用程序使用foreman run在本地运行正常,当我runserver.py使用执行我的文件时python runserver.py.当我把它推到Heroku时,它只是崩溃了.我甚至对我的procfile进行了更改:web: python runserver.py ${PORT}这样Heroku将绑定到一个端口号,但无济于事......我已经在这个问题上待了将近3天了.首先是我Procfile和现在的Heroku ...任何帮助都会很高兴得到赞赏.另外,我在这个项目中使用带有Flask框架的Python - 我遇到了Heroku前进,但它似乎只适用于RoR应用程序..
2014-02-24T02:24:50.146153+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-02-24T02:24:51.323561+00:00 heroku[web.1]: Process exited with status 137
2014-02-24T02:24:51.333621+00:00 heroku[web.1]: State changed from starting to crashed
2014-02-24T02:24:51.334368+00:00 heroku[web.1]: State changed from crashed to starting
2014-02-24T02:24:55.793531+00:00 heroku[web.1]: Starting process with command `python runserver.py`
2014-02-24T02:24:57.117683+00:00 app[web.1]: * Running on http://127.0.0.1:5000/
2014-02-24T02:24:57.117683+00:00 app[web.1]: * Restarting with reloader
2014-02-24T02:23:43.987388+00:00 heroku[api]: Deploy c55f7b6 by shaunktw@gmail.com
2014-02-24T02:23:43.987478+00:00 heroku[api]: Release v8 created by shaunktw@gmail.com
2014-02-24T02:25:56.204701+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-02-24T02:25:56.204929+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-02-24T02:25:57.495657+00:00 heroku[web.1]: Process exited with status 137
Run Code Online (Sandbox Code Playgroud)
Procfile:
web: python runserver.py ${PORT}
Run Code Online (Sandbox Code Playgroud)
runserver.py:
from intro_to_flask import app
app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)
我找到了这个问题的答案......基本上我必须绑定一个端口并指定我正在使用的主机:
在我的runserver.py文件中,我使用以下方法修改它:
import os
from intro_to_flask import app
port = int(os.environ.get("PORT", 5000))
app.run(debug=True, host='0.0.0.0', port=port)
Run Code Online (Sandbox Code Playgroud)
它可能不是最优雅的方式.但它确实有效.
| 归档时间: |
|
| 查看次数: |
3345 次 |
| 最近记录: |