dumpstr
dumpstr copied to clipboard
Mongodb open connections
Hey, the current dumpstr library never closes any database connections, therefor it leaves 5 open connections per database that you backup. I use this library to backup my database on a daily base and I noticed on my monintoring system that every time I run the back up, the open connections were increased by 5 per database.
Fix in mongoInfo.js
var MongoClient = require('mongodb').MongoClient;
function getCollections (uri, cb) { establishConnection(uri, function (err, client) { if (err) { return cb(err); } client.collectionNames(function(error, result) { cb(error, result); client.close(); }); }); }
function establishConnection (uri, cb) {
MongoClient.connect(uri, cb);
}
module.exports = { getCollections: getCollections }