当前位置: 首页 > 知识库问答 >
问题:

部署到Heroku的Strapi在生产中崩溃了?

丁阳羽
2023-03-14

我有一个应用程序,其中前端部署到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 env变量,应用程序在本地运行良好。我在免费层使用Mongo Atlas,所以我想知道这是否与此有关?有人知道问题出在哪里吗?

共有1个答案

拓拔德馨
2023-03-14

在发表这篇文章之前,我花了24小时试图修复它,就这样——发表这篇文章半小时后——我修复了它,这要归功于这个SO回答。我需要将IP地址列入白名单,以便允许MongoDB和Heroku之间的连接!

 类似资料:
  • 我的应用程序似乎总是在部署后崩溃。 2015-07-21T13:29:28.127452+00:00 Heroku[router]:at=error code=h10 desc=“应用程序崩溃”method=get path=“/api/v1/sessions”host=calm-hamlet-5165.herokuapp.com request_id=69711e3a-913e-45ed-b4b

  • 因此,我阅读了有关部署的内容,并多次尝试在Heroku上部署。不能让它工作。 错误日志: 2017-02-13T04:48:13.132359+00:00Heroku[Web.1]:状态从崩溃更改为启动 2017-02-13T04:48:17.100053+00:00Heroku[Web.1]:使用命令启动进程 2017-02-13T04:48:20.884225+00:00Heroku[Web.

  • 我有一个错误应用程序在我的本地电脑上工作,但当我把它发送给heroku时,它崩溃了。错误日志给出错误H10&表示: 编辑: 有没有人以前有过这种情况,并且知道是什么导致了这个问题?我找不到解决办法。 多谢了。

  • 我已经在我自己的服务器上做了一个原型应用程序,一个伟大的工作。但是在将它部署到Meteor.com时,我无法让它工作。昨天还好好的,但突然停了。有停电吗? 围绕pedacity.js:4 关于pedacity.js:100,这一行在我的文件中不存在...那应该是Meteor自动添加的clousure。

  • 我正在尝试将我的应用程序部署到Heroku,但一直崩溃。我使用CLI打开我的应用程序,它仍然崩溃,我甚至在Keroku仪表板上部署分支,它仍然崩溃。我想知道我的app.js或packjson出了什么问题。 这是我得到的错误: 2019-06-19T12:32:14.679424 00:00 heroku[路由器]: at=错误码=H10 desc="应用程序崩溃"方法=GET路径="/"主机=gu

  • 目标: 将我的strapi服务器部署到heroku,这样我就可以有一个无头的CMS。 错误: 系统: node.js版本:12.13.0 NPM版本:6.12.0 strapi版本:3.0.0-beta.17.4 数据库:MongoDB atlas Cloud 操作系统:LinuxMint 19.2 Cinnamon 前端:React 16.11.0 我试过: Strapi heroku部署指南