Added MongoDbChangeStream option.

This commit is contained in:
Ylian Saint-Hilaire 2019-05-28 17:42:11 -07:00
parent 8416b0a0aa
commit 162de5153b
3 changed files with 8 additions and 7 deletions

6
db.js
View File

@ -230,8 +230,8 @@ module.exports.CreateDB = function (parent, func) {
});
// Setup the changeStream on the MongoDB main collection if possible
try {
obj.fileChangeStream = obj.file.watch([{ $match: { 'fullDocument.type': { $in: [ 'node', 'mesh', 'user' ] } } }], { fullDocument: 'updateLookup' });
if (parent.args.mongodbchangestream == true) {
obj.fileChangeStream = obj.file.watch([{ $match: { 'fullDocument.type': { $in: ['node', 'mesh', 'user'] } } }], { fullDocument: 'updateLookup' });
obj.fileChangeStream.on('change', function (change) {
switch (change.fullDocument.type) {
case 'node': { dbNodeChange(change); break; } // A node has changed
@ -240,7 +240,7 @@ module.exports.CreateDB = function (parent, func) {
}
});
obj.changeStream = true;
} catch (ex) { }
}
// Setup MongoDB events collection and indexes
obj.eventsfile = db.collection('events'); // Collection containing all events

View File

@ -869,12 +869,12 @@ function CreateMeshCentralServer(config, args) {
obj.updateServerState('state', 'running');
// Setup auto-backup defaults
if (obj.config.settings.autobackup == null) { obj.config.settings.autobackup = { backupinvervalhours: 24, keeplastdaysbackup: 10 }; }
if (obj.config.settings.autobackup == null) { obj.config.settings.autobackup = { backupintervalhours: 24, keeplastdaysbackup: 10 }; }
else if (obj.config.settings.autobackup === false) { delete obj.config.settings.autobackup; }
// Setup auto-backup timer
if (obj.config.settings.autobackup && (typeof obj.config.settings.autobackup.backupinvervalhours == 'number')) {
setInterval(obj.db.performBackup, obj.config.settings.autobackup.backupinvervalhours * 60 * 60 * 1000);
if (obj.config.settings.autobackup && (typeof obj.config.settings.autobackup.backupintervalhours == 'number')) {
setInterval(obj.db.performBackup, obj.config.settings.autobackup.backupintervalhours * 60 * 60 * 1000);
}
});
});

View File

@ -3,6 +3,7 @@
"settings": {
"_Cert": "myserver.mydomain.com",
"_MongoDb": "mongodb://127.0.0.1:27017/meshcentral",
"_MongoDbChangeStream": true,
"_WANonly": true,
"_LANonly": true,
"_Minify": 1,
@ -41,7 +42,7 @@
]
},
"_AutoBackup": {
"backupInvervalHours": 24,
"backupIntervalHours": 24,
"keepLastDaysBackup": 10,
"zipPassword": "MyReallySecretPassword3",
"_backupPath": "C:\\backups"