forked from control-tower/ct-stadistics-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cron.js
21 lines (19 loc) · 824 Bytes
/
cron.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require('app-module-path').addPath(__dirname);
const CronJob = require('cron').CronJob;
const mongoose = require('mongoose');
const debug = require('debug')('stadistics-plugin');
const StadisticService = require('./lib/stadistic.service');
module.exports = function cron(plugin, generalConfig) {
debug('Loading stadistics cron');
const connection = mongoose.createConnection(`${generalConfig.mongoUri}`);
const stadisticService = new StadisticService(connection);
async function tick() {
try {
debug('Executing tick in stadistics microservice');
await stadisticService.completeGeoInfo();
} catch (error) {
debug('Error: ', error);
}
}
new CronJob('00 * * * * *', tick, null, true, 'America/Los_Angeles'); // eslint-disable-line no-new
};