| 44 | |
| 45 | |
| 46 | function _getDatabases() { |
| 47 | const deferred = q.defer(); |
| 48 | |
| 49 | try { |
| 50 | config.mongoClient.command({ listDatabases: 1 }, (err, databaseStatList) => { |
| 51 | if (err) { |
| 52 | deferred.reject(err); |
| 53 | } else if (databaseStatList) { |
| 54 | // Exclude Databases |
| 55 | const excludeDBList = ['_Analytics', '_GLOBAL', 'local']; |
| 56 | const databaseNameList = []; |
| 57 | for (let i = 0; i < databaseStatList.databases.length; ++i) { |
| 58 | if (excludeDBList.indexOf(databaseStatList.databases[i].name) < 0) { |
| 59 | databaseNameList.push(databaseStatList.databases[i].name); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | deferred.resolve(databaseNameList); |
| 64 | } |
| 65 | }); |
| 66 | } catch (err) { |
| 67 | winston.log('error', { error: String(err), stack: new Error().stack }); |
| 68 | } |
| 69 | |
| 70 | return deferred.promise; |
| 71 | } |
| 72 | |
| 73 | const job = new CronJob('00 00 22 * * *', (() => { |
| 74 | try { |