Skip to content

Commit a15f9a4

Browse files
committed
Configurable threshold of Cleaner plugin
1 parent ce29030 commit a15f9a4

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

plugins/cleaner.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ var preconditions = require('preconditions').singleton();
44
var microtime = require('microtime');
55
var cron = require('cron');
66
var CronJob = cron.CronJob;
7-
7+
var Threshold = (process.env.CLEANER_THRESHOLD_DAYS || 30) *24*60*60; // in seconds
88

99
module.exports.init = function(config) {
1010
var cronTime = config.cronTime || '0 * * * *';
11-
logger.info('Using cleaner plugin with cronTime ' + cronTime);
11+
logger.info('Using cleaner plugin with cronTime ' + cronTime + ' and threshold of ' + Threshold + ' seconds');
1212
var onTick = function() {
13-
var limit = microtime.now() - 1000 * 1000 * config.threshold;
13+
var limit = microtime.now() - 1000 * 1000 * Threshold;
1414
mdb.removeUpTo(limit, function(err, n) {
1515
if (err) logger.error(err);
1616
else logger.info('Ran cleaner task, removed ' + n);

plugins/config-cleaner.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module.exports = {
22

33
cronTime: '0 * * * *', // run each hour
4-
threshold: 30*24*60*60, // 30 days, in seconds
54

65
};

0 commit comments

Comments
 (0)