【发布时间】:2019-10-02 18:18:49
【问题描述】:
我正在尝试使用 Heroku 托管一个 api(使用 this 教程),但是当我将它上传到 heroku 时它一直在崩溃。我也无法使用 api 发布 GET PATCH 或任何内容。
这里是日志:
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
这是什么意思?提前致谢。
【问题讨论】:
-
欢迎来到 SO!不看代码很难说,但
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch看起来是这里的主要问题。 -
尝试通过 heroku-forward
https://artsy.github.io/blog/2012/12/13/beat-heroku-60-seconds-application-boot-timeout-with-a-proxy/987654324@的代理实现来增加超时时间