【问题标题】:Strapi deployed to Heroku is crashing in production?部署到 Heroku 的 Strapi 在生产中崩溃了吗?
【发布时间】:2020-11-26 22:30:37
【问题描述】:

我有一个应用程序,其中前端部署到 Netlify,而 Strapi 后端部署到 Heroku。我最近将 Strapi 从 v3.0.6 升级到 v3.1.3。我以前在生产环境中使用 PostgresQL,所以随着 Strapi 的升级,我也试图转移到 MongoDB。

我正在尝试将我的后端部署到生产环境,但是我不断收到 503 错误并且应用程序崩溃。您可以从下面的错误日志中看到连接到 Mongo 数据库时出现问题。

这是我从 Heroku 获得的相关日志:

2020-08-06T15:06:49.848463+00:00 app[web.1]: > backend@0.1.0 start /app
2020-08-06T15:06:49.848464+00:00 app[web.1]: > strapi start
2020-08-06T15:06:49.848465+00:00 app[web.1]:
2020-08-06T15:06:52.238840+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
2020-08-06T15:06:52.238869+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2020-08-06T15:06:52.239130+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
2020-08-06T15:06:52.239199+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
2020-08-06T15:06:52.239276+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
2020-08-06T15:07:10.279519+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=<app-name>.herokuapp.com request_id=9e81f113-1003-42f7-82e7-59296dc1f0f8 fwd="24.19.220.31" dyno= connect= service= status=503 bytes= protocol=https
2020-08-06T15:07:22.242572+00:00 app[web.1]: [2020-08-06T15:07:22.241Z] debug ⛔️ Server wasn't able to start properly.
2020-08-06T15:07:22.243944+00:00 app[web.1]: [2020-08-06T15:07:22.243Z] error Error connecting to the Mongo database. Server selection timed out after 30000 ms
2020-08-06T15:07:22.266318+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-08-06T15:07:22.266611+00:00 app[web.1]: npm ERR! errno 1
2020-08-06T15:07:22.269156+00:00 app[web.1]: npm ERR! backend@0.1.0 start: `strapi start`
2020-08-06T15:07:22.269330+00:00 app[web.1]: npm ERR! Exit status 1
2020-08-06T15:07:22.269513+00:00 app[web.1]: npm ERR!
2020-08-06T15:07:22.269976+00:00 app[web.1]: npm ERR! Failed at the backend@0.1.0 start script.
2020-08-06T15:07:22.270129+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-06T15:07:22.278069+00:00 app[web.1]:
2020-08-06T15:07:22.278314+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-06T15:07:22.278417+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-08-06T15_07_22_271Z-debug.log
2020-08-06T15:07:22.355748+00:00 heroku[web.1]: Process exited with status 1
2020-08-06T15:07:22.394507+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-06T15:07:23.802505+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=<app-name>.herokuapp.com request_id=f5876daf-f945-46b8-88c0-08a61106cfc5 fwd="24.19.220.31" dyno= connect= service= status=503 bytes= protocol=https

我在 Heroku 中设置了 Mongo URI 环境变量,并且应用程序在本地运行良好。我在免费层中使用 Mongo Atlas,所以我想知道这是否与它有关?有谁知道可能是什么问题?

【问题讨论】:

    标签: mongodb heroku strapi


    【解决方案1】:

    在发布这篇文章之前,我花了 24 小时尝试修复它,就像这样 - 在发布这篇文章后半小时 - 我修复了它,感谢 SO answer。我需要将 IP 地址列入白名单以允许 MongoDB 和 Heroku 之间的连接!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-07
      • 1970-01-01
      • 2020-04-09
      • 2012-10-02
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      相关资源
      最近更新 更多