最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

heroku应用程序错误,应用程序崩溃了Node.js

IT培训 admin 6浏览 0评论

heroku应用程序错误,应用程序崩溃了Node.js

我有一个连接到猫鼬的快速应用程序,这是我的[[package.json

{ "name": "backend", "version": "1.0.0", "description": "", "main": "app.js", "scripts": { "start": "node app.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "body-parser": "^1.19.0", "cookie-parser": "^1.4.4", "cors": "^2.8.5", "express": "^4.17.1", "helmet": "^3.21.1", "jsonwebtoken": "^8.5.1", "mongoose": "^5.7.4", "morgan": "^1.9.1" } }
和我的procfile

web:节点app.js

and this is the error i get from the logs 2019-10-15T22:49:24.862621+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/" host=boutique2backend.herokuapp request_id=7d85289 5-32ec-4958-84f9-4b6f1c185539 fwd="41.40.131.141" dyno= connect= service= status =503 bytes= protocol=https 2019-10-15T22:49:25.325894+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/favicon.ico" host=boutique2backend.herokuapp request _id=1aa4b90e-040d-4cc0-9b79-b4cf28b2c804 fwd="41.40.131.141" dyno= connect= serv ice= status=503 bytes= protocol=https

当我重新启动应用程序时得到

2019-10-15T22:50:07.470079+00:00 heroku[web.1]: State changed from crashed to st arting 2019-10-15T22:50:09.525567+00:00 heroku[web.1]: Starting process with command `: node app.js` 2019-10-15T22:50:11.621514+00:00 heroku[web.1]: Process exited with status 0 2019-10-15T22:50:11.666391+00:00 heroku[web.1]: State changed from starting to c rashed

我双重确保将端口设置为env变量

const PORT = process.env.PORT || 3002;

回答如下:这曾经发生在我身上,而这些都是罪魁祸首

  • 我有一个名为https-localHost的npm模块当您要测试时,它会为您提供ssl,让我们说与facebook,google或任何其他OAuth进行身份验证解决方案是

    简单卸载模块或停止使用它

  • 我没有设置环境变量您可以使用此命令在控制台上执行]

heroku config:set myEnvironmentVariable=234234

    由于我使用mongodb,heroku上的应用程序无法连接到我的PC上的本地实例,因此我不得不再次使用环境变量从Mlab提供一个实例
  • 我建议您使用winston根据他们的说法

    winston被设计为一个简单且通用的日志记录库,支持多种传输。传输实质上是日志的存储设备。

    它将允许您将错误存储在文件中,当您从ssh或从Heroku仪表板ssh进行访问时,可以从控制台访问这些文件,以便更好地查看您的错误并了解问题的根源。实际的heroku日志不会真正向您显示这些错误干杯!

  • heroku应用程序错误,应用程序崩溃了Node.js

    我有一个连接到猫鼬的快速应用程序,这是我的[[package.json

    { "name": "backend", "version": "1.0.0", "description": "", "main": "app.js", "scripts": { "start": "node app.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "body-parser": "^1.19.0", "cookie-parser": "^1.4.4", "cors": "^2.8.5", "express": "^4.17.1", "helmet": "^3.21.1", "jsonwebtoken": "^8.5.1", "mongoose": "^5.7.4", "morgan": "^1.9.1" } }
    和我的procfile

    web:节点app.js

    and this is the error i get from the logs 2019-10-15T22:49:24.862621+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/" host=boutique2backend.herokuapp request_id=7d85289 5-32ec-4958-84f9-4b6f1c185539 fwd="41.40.131.141" dyno= connect= service= status =503 bytes= protocol=https 2019-10-15T22:49:25.325894+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/favicon.ico" host=boutique2backend.herokuapp request _id=1aa4b90e-040d-4cc0-9b79-b4cf28b2c804 fwd="41.40.131.141" dyno= connect= serv ice= status=503 bytes= protocol=https

    当我重新启动应用程序时得到

    2019-10-15T22:50:07.470079+00:00 heroku[web.1]: State changed from crashed to st arting 2019-10-15T22:50:09.525567+00:00 heroku[web.1]: Starting process with command `: node app.js` 2019-10-15T22:50:11.621514+00:00 heroku[web.1]: Process exited with status 0 2019-10-15T22:50:11.666391+00:00 heroku[web.1]: State changed from starting to c rashed

    我双重确保将端口设置为env变量

    const PORT = process.env.PORT || 3002;

    回答如下:这曾经发生在我身上,而这些都是罪魁祸首

    • 我有一个名为https-localHost的npm模块当您要测试时,它会为您提供ssl,让我们说与facebook,google或任何其他OAuth进行身份验证解决方案是

      简单卸载模块或停止使用它

    • 我没有设置环境变量您可以使用此命令在控制台上执行]

    heroku config:set myEnvironmentVariable=234234

      由于我使用mongodb,heroku上的应用程序无法连接到我的PC上的本地实例,因此我不得不再次使用环境变量从Mlab提供一个实例
  • 我建议您使用winston根据他们的说法

    winston被设计为一个简单且通用的日志记录库,支持多种传输。传输实质上是日志的存储设备。

    它将允许您将错误存储在文件中,当您从ssh或从Heroku仪表板ssh进行访问时,可以从控制台访问这些文件,以便更好地查看您的错误并了解问题的根源。实际的heroku日志不会真正向您显示这些错误干杯!

  • 发布评论

    评论列表 (0)

    1. 暂无评论