最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Heroku Web不断崩溃(托管API)

运维笔记admin9浏览0评论

Heroku Web不断崩溃(托管API)

Heroku Web不断崩溃(托管API)

我正在尝试使用Heroku托管一个api(使用this教程),但是当我将其上传到heroku时,它总是崩溃。我也无法使用api发布获取补丁或任何内容。

以下是日志:

2019-09-30T01:07:09+00:00 app[api]: Build succeeded
2019-09-30T01:07:11.087893+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-09-30T01:07:14.671296+00:00 heroku[web.1]: source=web.1 dyno=heroku.147978494.47f1afa0-64a4-42ab-a289-4e26dbfb7138 sample#memory_total=28.04MB sample#memory_rss=28.04MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=8074pages sample#memory_pgpgout=895pages sample#memory_quota=512.00MB
2019-09-30T01:07:14.456882+00:00 app[web.1]: MongoDB connection with retry
2019-09-30T01:07:14.69389+00:00 app[web.1]: app listening at port 3600
2019-09-30T01:07:14.741028+00:00 app[web.1]: (node:4) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2019-09-30T01:07:16.534632+00:00 app[web.1]: MongoDB is connected
2019-09-30T01:07:37.004919+00:00 heroku[web.1]: source=web.1 dyno=heroku.147978494.47f1afa0-64a4-42ab-a289-4e26dbfb7138 sample#memory_total=28.86MB sample#memory_rss=28.86MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=8284pages sample#memory_pgpgout=895pages sample#memory_quota=512.00MB
2019-09-30T01:07:57.936203+00:00 heroku[web.1]: source=web.1 dyno=heroku.147978494.47f1afa0-64a4-42ab-a289-4e26dbfb7138 sample#load_avg_1m=0.49
2019-09-30T01:07:57.966933+00:00 heroku[web.1]: source=web.1 dyno=heroku.147978494.47f1afa0-64a4-42ab-a289-4e26dbfb7138 sample#memory_total=22.18MB sample#memory_rss=22.18MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=9600pages sample#memory_pgpgout=3923pages sample#memory_quota=512.00MB
2019-09-30T01:08:11.321679+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-09-30T01:08:11.348573+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-09-30T01:08:11.46165+00:00 heroku[web.1]: Process exited with status 137
2019-09-30T01:08:11.523496+00:00 heroku[web.1]: State changed from starting to crashed
2019-09-30T01:08:12.977371+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/users" host=castor-api-test-1.herokuapp request_id=b11ce11c-7934-4ee5-a9a3-cb9d70c68394 fwd="175.136.22.227" dyno= connect= service= status=503 bytes= protocol=https
2019-09-30T01:09:32.635588+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/users" host=castor-api-test-1.herokuapp request_id=3fb433e2-13d9-4e1f-ab66-f93dd9ca86ae fwd="175.136.22.227" dyno= connect= service= status=503 bytes= protocol=https

这是什么意思?预先感谢。

回答如下:

这里首先有2条日志行,这可能是原因:

2019-09-30T01:08:11.321679+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

这是Heroku平台提出的错误。这意味着您的应用程序无法快速启动,或者您没有绑定到正确的端口。在日志中往后看:

2019-09-30T01:07:14.69389+00:00 app[web.1]: app listening at port 3600

建议您的应用程序绑定到端口3600。Heroku要求应用程序绑定到PORT环境变量提供的端口号,该端口号通常比3600高得多,因此看起来您绑定到了Web的默认端口应用服务器,这意味着Heroku运行时无法检测您的应用是否正在运行并准备接收请求。对于nodejs服务器,这通常需要确保您在服务器启动配置中使用app.listen(process.env.PORT)

发布评论

评论列表(0)

  1. 暂无评论