index.js
1.31 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
const increRelationTask = require('./incre-relation-task');
const priceDayTask = require('./price-day-task');
const price30DayTask = require('./price-30day-task');
const price60DayTask = require('./price-60day-task');
const price180DayTask = require('./price-180day-task');
const clearTask = require('./clear-task');
const dayjs = require('dayjs');
const {logger} = require('../../libs/logger');
const jobCallback = (task) => {
return () => {
logger.info(`[process] task start ${task.name}`);
task(dayjs().unix());
};
};
module.exports = [{
cron: '0 10 2 * * *', // 每天2点10分执行,新增ufo和毒、淘宝关系task
task: jobCallback(increRelationTask)
}, {
cron: '0 0 */2 * * *', // 每两个小时执行,爬取毒、ufo、淘宝价格task
task: jobCallback(priceDayTask)
}, {
cron: '0 0 1,13 * * *', // 每天01点00分和13点00分执行,从day数据中取数据到30day
task: jobCallback(price30DayTask)
}, {
cron: '0 1 1 * * *', // 每天01点01分执行,从day数据中取数据到60day
task: jobCallback(price60DayTask)
}, {
cron: '0 2 1 * * *', // 每天01点02分执行,从day数据中取数据到180day,task内部判断3天间隔
task: jobCallback(price180DayTask)
}, {
cron: '0 3 1 * * *', // 每天01点03分执行,清理各表数据
task: jobCallback(clearTask)
}];