app.js
2.21 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const express = require('express');
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 spiderAllTask = require('./tasks/spider-all-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');
const pageCheckTask = require('./tasks/check-du-task');
const londonTask = require('./tasks/london-task');
const app = express();
global.isProduction = process.env.NODE_ENV === 'production';
global.sender = new Sender(config.monitorReport); // 初始化数据上报
//schedule.scheduleJob('0 15 6-23 * * *', () => {
// logger.info('[process]task start spiderTask'); // 比价任务
// spiderTask(dayjs().unix());
//});
// schedule.scheduleJob('0 0 * * * *', () => {
// logger.info('[process]task start spiderAllTask'); // 比价任务-all
// spiderAllTask(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); // 启动所有价格区间任务
// });
schedule.scheduleJob('0 0 * * * *', () => {
logger.info('[process]task start checkPageTask'); // 检测毒网页接口版本
pageCheckTask();
});
schedule.scheduleJob('0 0 16 * * *', () => {
logger.info('[process]task start londonTask'); // londonboy 废弃
londonTask();
});
// docker验证项目是否正常发布
app.use('/node/status.html', (req, res) => {
return res.status(200).end();
});
// listener
app.listen(config.port, function() {
logger.info('spider start');
});