mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-23 12:52:15 +00:00
Better logging on database errors
This commit is contained in:
parent
61350d94e9
commit
8a1c3a4b43
1 changed files with 21 additions and 2 deletions
23
db/index.js
23
db/index.js
|
@ -4,7 +4,26 @@ var path = require("path");
|
||||||
var mongoose = require("mongoose");
|
var mongoose = require("mongoose");
|
||||||
var config = require(path.join(__dirname, "../config/config.js"));
|
var config = require(path.join(__dirname, "../config/config.js"));
|
||||||
|
|
||||||
mongoose.connect(config.mongo.uri);
|
var connect = function () {
|
||||||
|
mongoose.connect(config.mongo.uri, {
|
||||||
|
server: {
|
||||||
|
socketOptions: {
|
||||||
|
keepAlive: 1,
|
||||||
|
connectTimeoutMS: 30000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
connect();
|
||||||
|
|
||||||
|
mongoose.connection.on("error", function (error) {
|
||||||
|
winston.error(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
mongoose.connection.on("disconnected", function () {
|
||||||
|
winston.error("MongoDB: Was disconnected.");
|
||||||
|
});
|
||||||
|
|
||||||
// Load models
|
// Load models
|
||||||
require(path.join(__dirname, "/models/message"));
|
require(path.join(__dirname, "/models/message"));
|
||||||
|
@ -12,4 +31,4 @@ require(path.join(__dirname, "/models/session"));
|
||||||
require(path.join(__dirname, "/models/profile"));
|
require(path.join(__dirname, "/models/profile"));
|
||||||
require(path.join(__dirname, "/models/archivedGather"));
|
require(path.join(__dirname, "/models/archivedGather"));
|
||||||
|
|
||||||
module.exports = mongoose;
|
module.exports = mongoose;
|
||||||
|
|
Loading…
Reference in a new issue