什么可能导致这个heroku崩溃?错误代码= H10

时间:2017-09-08 02:30:56

标签: express heroku sequelize.js auth0

我查看了过去关于这个问题的帖子,很多人建议heroku重启,或者重启dynos,或者确保使用var PORT = process.env.PORT || 3000.我已经做了所有这些,但我的应用程序仍然崩溃。该应用程序使用node / express sequelize / auth0运行。

有人有任何建议吗?谢谢!

以下是日志:

 2017-09-08T02:11:37.293051+00:00 app[web.1]:     at emitOne 
(events.js:96:13)
2017-09-08T02:11:37.293052+00:00 app[web.1]:     at Socket.emit 
(events.js:188:7)
2017-09-08T02:11:37.293053+00:00 app[web.1]:     at emitErrorNT 
(net.js:1277:8)
2017-09-08T02:11:37.293054+00:00 app[web.1]:     at 
_combinedTickCallback (internal/process/next_tick.js:80:11)
2017-09-08T02:11:37.293055+00:00 app[web.1]:     at 
process._tickCallback (internal/process/next_tick.js:104:9)
2017-09-08T02:11:37.364314+00:00 heroku[web.1]: State changed from 
starting to crashed
2017-09-08T02:11:37.353673+00:00 heroku[web.1]: Process exited with 
status 0
2017-09-08T02:11:49.712881+00:00 heroku[router]: at=error code=H10 
desc="App crashed" method=GET path="/" host=roadie2.herokuapp.com 
request_id=79e0bc3a-aa28-44bb-ab80-cfcf4f6cd97d fwd="99.92.51.34" 
dyno= connect= service= status=503 bytes= protocol=https
2017-09-08T02:11:50.564503+00:00 heroku[router]: at=error code=H10 
desc="App crashed" method=GET path="/favicon.ico" 
host=roadie2.herokuapp.com request_id=c72e5077-494c-41f5-8be1-
f0c2c329d080 fwd="99.92.51.34" dyno= connect= service= status=503 
bytes= protocol=https
2017-09-08T02:12:24.838901+00:00 heroku[router]: at=error code=H10 
desc="App crashed" method=GET path="/" host=roadie2.herokuapp.com 
request_id=ca551858-5372-40c9-abf1-670176b159dc fwd="99.92.51.34" 
dyno= connect= service= status=503 bytes= protocol=https
2017-09-08T02:12:25.340624+00:00 heroku[router]: at=error code=H10 
desc="App crashed" method=GET path="/favicon.ico" 
host=roadie2.herokuapp.com request_id=c37b876d-5a59-40d0-9d59-
9be013c58d94 fwd="99.92.51.34" dyno= connect= service= status=503 
bytes= protocol=https

以下是输入heroku日志后结果的最后一部分--tail

2017-09-08T02:11:27.589912+00:00 heroku[web.1]: State changed from 
crashed to starting
2017-09-08T02:11:29.599921+00:00 heroku[web.1]: Starting process with 
command `npm start`
2017-09-08T02:11:32.504222+00:00 app[web.1]:
2017-09-08T02:11:32.504242+00:00 app[web.1]: > 15.2@1.0.0 start /app
2017-09-08T02:11:32.504243+00:00 app[web.1]: > node server.js
2017-09-08T02:11:32.504243+00:00 app[web.1]:
2017-09-08T02:11:33.199936+00:00 app[web.1]: Unhandled rejection 
SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
2017-09-08T02:11:33.199952+00:00 app[web.1]:     at 
Handshake._callback 
(/app/node_modules/sequelize/lib/dialects/mysql/connection-
manager.js:80:20)
2017-09-08T02:11:33.199953+00:00 app[web.1]:     at 
Protocol.handleNetworkError 
(/app/node_modules/mysql/lib/protocol/Protocol.js:364:14)
2017-09-08T02:11:33.199953+00:00 app[web.1]:     at 
Connection._handleNetworkError 
(/app/node_modules/mysql/lib/Connection.js:428:18)
2017-09-08T02:11:33.199954+00:00 app[web.1]:     at emitOne 
(events.js:96:13)
2017-09-08T02:11:33.199952+00:00 app[web.1]:     at 
Handshake.Sequence.end 
(/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:86:24)
2017-09-08T02:11:33.199954+00:00 app[web.1]:     at Socket.emit 
(events.js:188:7)
2017-09-08T02:11:33.199955+00:00 app[web.1]:     at emitErrorNT 
(net.js:1277:8)
2017-09-08T02:11:33.199956+00:00 app[web.1]:     at 
_combinedTickCallback (internal/process/next_tick.js:80:11)
2017-09-08T02:11:33.199956+00:00 app[web.1]:     at 
process._tickCallback (internal/process/next_tick.js:104:9)
2017-09-08T02:11:33.302346+00:00 heroku[web.1]: State changed from 
starting to crashed
2017-09-08T02:11:33.305267+00:00 heroku[web.1]: State changed from . 
crashed to starting
2017-09-08T02:11:33.286200+00:00 heroku[web.1]: Process exited with . 
status 0
2017-09-08T02:11:34.845606+00:00 heroku[web.1]: Starting process with 
command `npm start`
2017-09-08T02:11:36.543285+00:00 app[web.1]:
2017-09-08T02:11:36.543298+00:00 app[web.1]: > 15.2@1.0.0 start /app
2017-09-08T02:11:36.543299+00:00 app[web.1]: > node server.js
2017-09-08T02:11:36.543299+00:00 app[web.1]:
2017-09-08T02:11:37.293030+00:00 app[web.1]: Unhandled rejection . 
SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
2017-09-08T02:11:37.293048+00:00 app[web.1]:     at 
Handshake._callback . 
(/app/node_modules/sequelize/lib/dialects/mysql/connection-
manager.js:80:20)
2017-09-08T02:11:37.293049+00:00 app[web.1]:     at 
Handshake.Sequence.end 
(/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:86:24)
2017-09-08T02:11:37.293049+00:00 app[web.1]:     at . 
Protocol.handleNetworkError 
(/app/node_modules/mysql/lib/protocol/Protocol.js:364:14)
2017-09-08T02:11:37.293050+00:00 app[web.1]:     at 
Connection._handleNetworkError 
(/app/node_modules/mysql/lib/Connection.js:428:18)
2017-09-08T02:11:37.293051+00:00 app[web.1]:     at emitOne 
(events.js:96:13)
2017-09-08T02:11:37.293052+00:00 app[web.1]:     at Socket.emit 
(events.js:188:7)
2017-09-08T02:11:37.293053+00:00 app[web.1]:     at emitErrorNT 
(net.js:1277:8)
2017-09-08T02:11:37.293054+00:00 app[web.1]:     at 
_combinedTickCallback (internal/process/next_tick.js:80:11)
2017-09-08T02:11:37.293055+00:00 app[web.1]:     at 
process._tickCallback (internal/process/next_tick.js:104:9)
2017-09-08T02:11:37.364314+00:00 heroku[web.1]: State changed from 
starting to crashed
2017-09-08T02:11:37.353673+00:00 heroku[web.1]: Process exited with . 
status 0
2017-09-08T02:11:49.712881+00:00 heroku[router]: at=error code=H10 . 
desc="Appcrashed" method=GET path="/" host=roadie2.herokuapp.com 
request_id=79e0bc3a-aa28-44bb-ab80-cfcf4f6cd97d fwd="99.92.51.34" 
dyno= connect= service= status=503 bytes= protocol=https
2017-09-08T02:11:50.564503+00:00 heroku[router]: at=error code=H10 
desc="Appcrashed" method=GET path="/favicon.ico" 
host=roadie2.herokuapp.com request_id=c72e5077-494c-41f5-8be1-
f0c2c329d080 fwd="99.92.51.34" dyno= connect= service= status=503 
bytes= protocol=https
2017-09-08T02:12:24.838901+00:00 heroku[router]: at=error code=H10 . 
desc="Appcrashed" method=GET path="/" host=roadie2.herokuapp.com 
request_id=ca551858-5372-40c9-abf1-670176b159dc fwd="99.92.51.34" 
dyno= connect= service= status=503 bytes= protocol=https
2017-09-08T02:12:25.340624+00:00 heroku[router]: at=error code=H10 
desc="Appcrashed" method=GET path="/favicon.ico" 
host=roadie2.herokuapp.com request_id=c37b876d-5a59-40d0-9d59-
9be013c58d94 fwd="99.92.51.34" dyno= connect= service= status=503 
 bytes= protocol=https

config.json

 {
 "development": {
"username": "root",
"password":"",
"database": "roadie2",
"host": "127.0.0.1",
"dialect": "mysql"
 },
"test": {
"username": "root",
"password": null,
"database": "database_test",
"host": "127.0.0.1",
"dialect": "mysql"
 },
 "production": {
"use_env_variable": "JAWSDB_URL",
"dialect": "mysql"
}
}

server.js

var express = require("express");
var bodyParser = require("body-parser");

// Sets up the Express App
// =============================================================
var app = express();
// var PORT = process.env.PORT || 3000;
var port = process.env.PORT 

// Requiring our models for syncing
var db = require("./models");

// Sets up the Express app to handle data parsing
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.text());
app.use(bodyParser.json({ type: "application/vnd.api+json" }));



// Static directory
app.use(express.static("./public"));

// Routes =============================================================

require("./routes/html-routes.js")(app);
require("./routes/api-routes.js")(app);

// Syncing our sequelize models and then starting our express app
db.sequelize.sync().then(function() {
  app.listen(port, function() {
    console.log("App listening on PORT " + port);
  });

});

模型/ index.js

'use strict';

var fs        = require('fs');
var path      = require('path');
var Sequelize = require('sequelize');
var basename  = path.basename(module.filename);
var env       = process.env.NODE_ENV || 'development';
var config    = require(__dirname + '/../config/config.json')[env];
var db        = {};

if (config.use_env_variable) {
  var sequelize = new 
Sequelize(process.env[config.use_env_variable]);
} else {
  var sequelize = new Sequelize(config.database, config.username, 
config.password, config);
}

fs
  .readdirSync(__dirname)
  .filter(function(file) {
    return (file.indexOf('.') !== 0) && (file !== basename) && 
(file.slice(-3) === '.js');
  })
  .forEach(function(file) {
    var model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
 });

Object.keys(db).forEach(function(modelName) {
  if (db[modelName].associate) {
  db[modelName].associate(db);
 }
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;

1 个答案:

答案 0 :(得分:0)

truc

您的日志清楚地告诉您崩溃的原因:

2017-09-08T02:11:37.293030+00:00 app[web.1]: Unhandled rejection . 
SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306

您无法连接到SQL服务器。

从它的外观来看,你似乎试图连接127.0.0.1:3306,这将无法正常工作。 127.0.0.1localhost是您当地的IP。

您需要设置/连接到https://devcenter.heroku.com/articles/error-codes#h10-app-crashed插件或使用外部SQL服务,例如Heroku's Postgres