Python heroku错误H20应用启动超时,R10启动超时

Python heroku错误H20应用启动超时,R10启动超时

问题描述:

我以示例为例: http://flask.pocoo.org/docs/quickstart/,并且可以在"foreman start"之后在自己的机器上很好地运行它,但是当我在heroku上部署它时,出现R10超时错误.

I do as the examples: http://flask.pocoo.org/docs/quickstart/, and I can run it well on my own machine after "foreman start", however when I deploy it on heroku, I got R10 timeout error.

我写了Procfileas:

I wrote the Procfileas :

web: python flaskr.py

并且为了运行"git push heroku master"命令,我删除了"disreibute == 0.6.24"这句话,因为如果没有,我将得到如下错误:

and in order to run the "git push heroku master" command, I delete the "disreibute==0.6.24" sentence because if not, I would get an error as follows:

Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'install' is not defined

所以我不知道这是Procfile还是requirements.txt文件是错误的还是其他错误.我几乎阅读了所有找到的文章,但问题尚未解决.

So I don't know whether it is the Procfile or the requirements.txt file is wrong or something else is wrong. I almost read all articles I have found but the problem is not solved yet.

此外,该示例使用了SQLite3数据库,我不知道它是否与此有关.

Besides, the example used SQLite3 database, I don't know whether it has something to do with this..

最后,我将在此处列出日志:

In the last, I will list the logs here:

at=error code=H20 desc="App boot timeout" method=GET path=/ host=tranquil-tor-4127.herokuapp.com request_id=8a088587-bee9-40e9-a686-0555843c191b fwd="8.35.201.53" dyno= connect= service= status=503 bytes=

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Stopping process with SIGKILL
Process exited with status 137
at=error code=H10 desc="App crashed" method=GET path=/ host=tranquil-tor-4127.herokuapp.com request_id=59ccb901-e988-430d-93e8-f83a8930e60b fwd="8.35.201.50" dyno= connect= service= status=503 bytes=
at=error code=H10 desc="App crashed" method=GET path=/ host=tranquil-tor-4127.herokuapp.com request_id=7b76850f-7c25-481f-8216-542d9baaa769 fwd="8.35.201.51" dyno= connect= service= status=503 bytes=
Slug compilation started
State changed from crashed to starting
at=error code=H10 desc="App crashed" method=GET path=/ host=tranquil-tor-4127.herokuapp.com request_id=5601bbce-b00c-4927-8d9c-ac534745859d fwd="8.35.201.52" dyno= connect= service= status=503 bytes=

我注意到slug编译可以正常完成,然后出现R10错误.

I noticed that slug compilation can finish normally and then R10 error follows.

针对我们的node.js应用程序的以下解决方案可能会帮助到这里结束的任何人.

The following solution for our node.js app might help anyone who ends up here.

听127.0.0.1会导致我们遇到 code = H20 desc =应用启动超时" 问题.将收听地址更改为0.0.0.0 即可解决问题.

Listening to 127.0.0.1 leads to the code=H20 desc="App boot timeout" problem for us. Changing the listening address to 0.0.0.0 solves the problem.

此外,不要使用您自己的端口,而是使用环境变量PORT ,该变量由heroku传递给您的应用环境变量.否则,您也会遇到此问题.

Also, don't use your own port, but instead use the environment variable PORT , which is passed to your app environment variables by heroku. Otherwise, you'll also get this problem.

这是我们的节点代码:

const { PORT=3000, LOCAL_ADDRESS='0.0.0.0' } = process.env
server.listen(PORT, LOCAL_ADDRESS, () => {
  const address = server.address();
  console.log('server listening at', address);
});

因此,请尝试记录您的监听地址和端口并首先进行检查.

So, try to log your listening address and port and check them firstly.