Authored by 陈峰

commit

... ... @@ -8,7 +8,7 @@ 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 priceTask = require('./tasks/price-task');
global.isProduction = process.env.NODE_ENV === 'production';
global.sender = new Sender(config.monitorReport); // 初始化数据上报
... ... @@ -28,7 +28,8 @@ schedule.scheduleJob('0 59 23 * * *', () => {
clearTask();
});
// schedule.scheduleJob('0 10 * * * *', () => {
// logger.info('[process]task start priceTask');
// priceTask();
// });
schedule.scheduleJob('0 10 1 * * *', () => {
logger.info('[process]task start priceTask');
priceTask();
});
priceTask();
... ...
... ... @@ -5,6 +5,7 @@
"script": "app.js",
"instances": "1",
"exec_mode": "cluster",
"merge_logs": true,
"log_date_format": "YYYY-MM-DD HH:mm:ss Z",
"error_file": "/Data/logs/node/spider-ufo-err.log",
"out_file": "/Data/logs/node/spider-ufo-out.log",
... ...
... ... @@ -51,36 +51,26 @@ const task = async(id) => {
const result = await spider.spiderFetch(id);
if (result.status === 200) {
const {detail, sizeList} = result.data;
const {detail, item} = result.data;
const productId = detail.productId;
const soldNum = detail.soldNum;
const articleNumber = detail.articleNumber;
// const sizes = sizeList.map(sizeItem => {
// return {
// size: sizeItem.size,
// price: _.isEmpty(sizeItem.item) ? 0 : sizeItem.item.price,
// soldNum: 0
// };
// });
// const dest = await processBuys({
// productId,
// soldNum,
// sizes
// });
const price = item.price || 0 / 100;
const title = detail.title;
return {
productId,
soldNum,
articleNumber
articleNumber,
price,
title
};
}
};
module.exports = async() => {
const now = dayjs().format('YYYY-MM-DD_HH');
const now = dayjs().format('YYYY-MM-DD');
const fw = fs.createWriteStream(`/Data/logs/node/prices/${now}.log`, {
flags: 'a'
});
... ...