The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/server/startup/cron.js

55 lines
1.1 KiB

/* global SyncedCron */
const logger = new Logger('SyncedCron');
SyncedCron.config({
logger(opts) {
return logger[opts.level].call(logger, opts.message);
},
collectionName: 'rocketchat_cron_history'
});
function generateStatistics() {
const statistics = RocketChat.statistics.save();
statistics.host = Meteor.absoluteUrl();
if (RocketChat.settings.get('Statistics_reporting')) {
try {
HTTP.post('https://collector.rocket.chat/', {
data: statistics
});
} catch (error) {
/*error*/
logger.warn('Failed to send usage report');
}
}
}
function cleanupOEmbedCache() {
return Meteor.call('OEmbedCacheCleanup');
}
Meteor.startup(function() {
return Meteor.defer(function() {
generateStatistics();
SyncedCron.add({
name: 'Generate and save statistics',
schedule(parser) {
return parser.cron(new Date().getMinutes() + ' * * * *');
},
job: generateStatistics
});
SyncedCron.add({
name: 'Cleanup OEmbed cache',
schedule(parser) {
const now = new Date();
return parser.cron(now.getMinutes() + ' ' + now.getHours() + ' * * *');
},
job: cleanupOEmbedCache
});
return SyncedCron.start();
});
});