Skip to content

Commit

Permalink
Configurable threshold of Cleaner plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgustavo committed Jan 20, 2015
1 parent ce29030 commit a15f9a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions plugins/cleaner.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ var preconditions = require('preconditions').singleton();
var microtime = require('microtime');
var cron = require('cron');
var CronJob = cron.CronJob;

var Threshold = (process.env.CLEANER_THRESHOLD_DAYS || 30) *24*60*60; // in seconds

module.exports.init = function(config) {
var cronTime = config.cronTime || '0 * * * *';
logger.info('Using cleaner plugin with cronTime ' + cronTime);
logger.info('Using cleaner plugin with cronTime ' + cronTime + ' and threshold of ' + Threshold + ' seconds');
var onTick = function() {
var limit = microtime.now() - 1000 * 1000 * config.threshold;
var limit = microtime.now() - 1000 * 1000 * Threshold;
mdb.removeUpTo(limit, function(err, n) {
if (err) logger.error(err);
else logger.info('Ran cleaner task, removed ' + n);
Expand Down
1 change: 0 additions & 1 deletion plugins/config-cleaner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {

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

};

0 comments on commit a15f9a4

Please sign in to comment.