app.js 691 Bytes
const schedule = require('node-schedule');
const Sender = require('influx-batch-sender');
const dayjs = require('dayjs');
const config = require('./config/index');
const {logger} = require('./libs/logger');

const spiderTask = require('./tasks/spider-task');
const calvAvgTask = require('./tasks/calc-task');

global.isProduction = process.env.NODE_ENV === 'production';
global.sender = new Sender(config.monitorReport); // 初始化数据上报

schedule.scheduleJob('0 */30 * * * *', () => {
  logger.info('task start spiderTask');
  spiderTask(dayjs().unix());
});

schedule.scheduleJob('0 10 * * * *', () => {
  logger.info('task start calvAvgTask');
  calvAvgTask();
});
calvAvgTask();