[英]Heroku and Node.js application deployment error H10 (App crashed)
[英]heroku application error, application crashed Node.js
我有一个连接到 mongoose 的快速应用程序,这是我的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.com 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.com 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;
这曾经发生在我身上,这些可能是罪魁祸首
I had a npm module called https-localHost which gives you ssl for when you want to test lets say authentication with facebook, google or any other OAuth whose solution was to simply uninstall the module or stop using it
我没有设置环境变量,您可以使用此命令在控制台上执行此操作
heroku config:set myEnvironmentVariable=234234
我会建议你使用根据他们的winston
winston 被设计成一个简单且通用的日志库,支持多种传输。 传输本质上是日志的存储设备。
它允许您将错误存储在文件中,当您将 ssh 输入或从 Heroku 仪表板中访问时,您可以从控制台访问这些文件,以便更好地了解您的错误并了解问题的根源日志实际上不会向您显示这些错误,干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.