Node,Heroku,应用程序错误,connect.session()MemoryStore不是为生产环境设计的

时间:2017-04-24 15:16:35

标签: node.js heroku sequelize.js

当我尝试部署到Heroku时,我的应用程序崩溃了,我正在使用Node。我认为问题是使用Sequelize连接到数据库。

错误代码= H10

我认为这与此处的问题相同: https://github.com/ga-wdi-exercises/project3/issues/127

Heroku Logs:

2017-04-24T07:42:40.134863+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2017-04-24T07:42:40.134878+00:00 app[web.1]: designed for a production environment, as it will leak
2017-04-24T07:42:40.134878+00:00 app[web.1]: memory, and will not scale past a single process.
2017-04-24T07:42:40.221903+00:00 app[web.1]:     at Handshake._callback (/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:80:20)
2017-04-24T07:42:40.221904+00:00 app[web.1]:     at Protocol.handleNetworkError (/app/node_modules/mysql/lib/protocol/Protocol.js:364:14)
2017-04-24T07:42:40.221906+00:00 app[web.1]:     at emitOne (events.js:96:13)
2017-04-24T07:42:40.221907+00:00 app[web.1]:     at emitErrorNT (net.js:1276:8)
2017-04-24T07:42:40.221904+00:00 app[web.1]:     at Handshake.Sequence.end (/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:86:24)
2017-04-24T07:42:40.221905+00:00 app[web.1]:     at Connection._handleNetworkError (/app/node_modules/mysql/lib/Connection.js:428:18)
2017-04-24T07:42:40.221906+00:00 app[web.1]:     at Socket.emit (events.js:188:7)
2017-04-24T07:42:40.221908+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:98:9)
2017-04-24T07:42:40.221900+00:00 app[web.1]: Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
2017-04-24T07:42:40.221908+00:00 app[web.1]:     at _combinedTickCallback (internal/process/next_tick.js:74:11)
2017-04-24T07:42:40.303076+00:00 heroku[web.1]: Process exited with status 0
2017-04-24T07:42:40.289877+00:00 heroku[web.1]: State changed from starting to crashed
2017-04-24T08:06:36.194005+00:00 heroku[web.1]: State changed from crashed to starting
2017-04-24T08:06:40.381609+00:00 heroku[web.1]: Starting process with command `node index.js`

Index.js:

var port = process.env.PORT || 8000;

db.sequelize.sync().then(() => {
  app.listen(port, () => {
    console.log('Web server started at port 8000!');
  });
});

配置:

module.exports = {
  "development": {
    "username": process.env.DB_USERNAME,
    "password": null,
    "database": "blog-app",
    "host": "127.0.0.1",
    "dialect": "postgres"
  },
  "test": {
    "username": process.env.DB_USERNAME,
    "password": null,
    "database": "blog-app-test",
    "host": "127.0.0.1",
    "dialect": "postgres"
  },
  "production": {
    "username": process.env.DB_USERNAME,
    "password": null,
    "database": "blog-app-production",
    "host": "127.0.0.1",
    "dialect": "postgres"
  }
};

的package.json:

{
  "name": "ScienceMotion",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "base64url": "^2.0.0",
    "bcryptjs": "^2.4.0",
    "body-parser": "^1.16.0",
    "bower": "^1.8.0",
    "express": "4.15.2",
    "express-routemap": "^1.0.2",
    "express-session": "^1.14.2",
    "method-override": "^2.3.7",
    "mocha": "^3.2.0",
    "morgan": "^1.7.0",
    "mysql": "^2.13.0",
    "nodemailer": "^2.7.0",
    "pg": "^6.1.5",
    "pg-native": "^1.10.0",
    "psql": "0.0.1",
    "pug": "^2.0.0-beta6",
    "sequelize": "^3.29.0",
    "slug": "^0.9.1"
  },
  "engines": {
    "node": "6.9.1",
    "npm": "4.0.5"
  }
}

0 个答案:

没有答案