Heroku Web 不断崩溃(托管 API)
Heroku Web keeps crashing (hosting an API)
我正在尝试使用 Heroku 托管一个 api(使用 this 教程),但是当我将它上传到 heroku 时它总是崩溃。我也无法 POST GET PATCH 或任何使用 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.com 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.com 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)
我正在尝试使用 Heroku 托管一个 api(使用 this 教程),但是当我将它上传到 heroku 时它总是崩溃。我也无法 POST GET PATCH 或任何使用 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.com 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.com 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)