问题描述
我的应用程序可以使用工头运行在本地正常运行,而当我使用python runserver.py
执行我的runserver.py
文件时.当我将其推到Heroku时,它崩溃了.我什至更改了我的procfile:web: python runserver.py ${PORT}
,以便Heroku可以绑定到端口号,但无济于事...我已经解决了近3天了.首先是我的Procfile
,现在是Heroku...任何帮助将不胜感激.另外,我在该项目的Flask框架中使用Python –我遇到了Heroku,但似乎只适用于RoR应用程序.
My app runs fine locally using foreman run, and when I execute my runserver.py
file using python runserver.py
. When I push it to Heroku, it just crashes. I even made changes to my procfile: web: python runserver.py ${PORT}
so that Heroku will bind to a port number, but to no avail...I've been at this problem for almost 3 days now. First with my Procfile
and now with Heroku...any help would gladly be appreciated. Additionally, I am using Python with the Flask framework for this project -- I came across Heroku forward, but it seems to be only for RoR applications..
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 [email protected]
2014-02-24T02:23:43.987478+00:00 heroku[api]: Release v8 created by [email protected]
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
Procfile:
web: python runserver.py ${PORT}
runserver.py:
runserver.py:
from intro_to_flask import app
app.run(debug=True)
推荐答案
我找到了此问题的答案...本质上,我必须绑定端口并指定要使用的主机:
I found the answer to this issue...essentially I had to bind a port and specify the host that I am using:
在我的runserver.py文件中,我使用以下命令对其进行了修改:
In my runserver.py file I modified it using:
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)
这可能不是最优雅的方法,但是它可以工作.
It's probably not the most elegant way of doing it.but it works.
这篇关于Heroku App立即崩溃,并出现R10和H10错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!