Skip to content
Permalink
Browse files

Merge pull request #1400 from leider/master

changing implementation of "close" with mongoDB
  • Loading branch information...
NicoleRauch committed Sep 4, 2019
2 parents d36ce68 + 2c522df commit d87f93044ad29e453ab01be297b2d392c96b1ddb
Showing with 14 additions and 8 deletions.
  1. +10 −6 softwerkskammer/lib/members/updateAvatarData.js
  2. +4 −2 softwerkskammer/lib/persistence/persistence.js
@@ -6,16 +6,20 @@ require('../../configure'); // initializing parameters
const async = require('async');
const beans = require('simple-configure').get('beans');
const store = beans.get('memberstore');
const persistence = beans.get('membersPersistence');

const service = beans.get('membersService');

store.allMembers((err, members) => {
if (err || !members) { console.log('avatar updater had problems loading members'); }
console.log('starting avatar update');
async.each(members, service.updateImage, err2 => {
if (err2) {
console.log('avatar updater encountered an error: ' + err2.message);
}
console.log('finishing avatar update');
console.log('starting avatar update');
async.each(members, service.updateImage, err2 => {
if (err2) {
console.log('avatar updater encountered an error: ' + err2.message);
}
console.log('finishing avatar update');
persistence.closeDB(() => {
process.exit();
});
});
});
@@ -1,6 +1,7 @@
const conf = require('simple-configure');
const async = require('async');
let ourDB;
let ourClient;
const loggers = require('winston').loggers;
const logger = loggers.get('transactions');
const scriptLogger = loggers.get('scripts');
@@ -191,6 +192,7 @@ module.exports = function persistenceFunc(collectionName) {
return logger.error(err);
}
ourDB = db;
ourClient = client;
ourDBConnectionState = DBSTATE.OPEN;
logInfo('DB state is now OPEN, db = ' + db);
});
@@ -202,8 +204,8 @@ module.exports = function persistenceFunc(collectionName) {
return;
}
performInDB(() => {
ourDB.unref();
ourDB = undefined;
ourClient.close();
ourClient = undefined;
ourDBConnectionState = DBSTATE.CLOSED;
logInfo('connection closed');
if (callback) { callback(); }

0 comments on commit d87f930

Please sign in to comment.
You can’t perform that action at this time.