app.js
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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');
const clearTask = require('./tasks/clear-task');
const priceTask = require('./tasks/price-task');
const priceLineTask = require('./tasks/price-line-task');
global.isProduction = process.env.NODE_ENV === 'production';
global.sender = new Sender(config.monitorReport); // 初始化数据上报
schedule.scheduleJob('0 */15 * * * *', () => {
logger.info('[process]task start spiderTask');
spiderTask(dayjs().unix());
});
schedule.scheduleJob('0 15 10 * * *', () => {
logger.info('[process]task start calvAvgTask');
calvAvgTask();
});
schedule.scheduleJob('0 59 23 * * *', () => {
logger.info('[process]task start clearTask');
clearTask();
});
schedule.scheduleJob('0 10 1 * * *', () => {
logger.info('[process]task start priceTask');
priceTask();
});
priceLineTask.forEach(taskInfo => {
schedule.scheduleJob(taskInfo.cron, taskInfo.task);
});