From a77c044b2fe31bec794b7eb0cb80e3416d3384a8 Mon Sep 17 00:00:00 2001 From: ChanceYu Date: Sun, 1 Dec 2024 23:33:18 +0800 Subject: [PATCH] update: use parallel limit --- server/update.js | 11 +++++------ server/utils.js | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server/update.js b/server/update.js index 82d76ba2a5..fbc37409a6 100644 --- a/server/update.js +++ b/server/update.js @@ -23,13 +23,12 @@ let newData = null /** * 更新 git 仓库 */ -function handleUpdate() { - if (utils.WORKFLOW) { - handleFeed() - } else { +async function handleUpdate() { + if (!utils.WORKFLOW) { utils.log('开始更新抓取') - git.pull().exec(handleFeed) + await git.pull() } + handleFeed() } /** @@ -98,7 +97,7 @@ function handleFeed() { })()) })) - Async.series(tasks, async () => { + Async.parallelLimit(tasks, 5, async () => { if (newData.length) { fs.outputJsonSync(LINKS_PATH, linksJson) await writemd(newData, linksJson) diff --git a/server/utils.js b/server/utils.js index 48385982fe..a776df61de 100644 --- a/server/utils.js +++ b/server/utils.js @@ -27,6 +27,8 @@ const tags = fs.readJsonSync(TAGS_PATH) */ const WORKFLOW = !!process.env.WORKFLOW +console.log('WORKFLOW:', WORKFLOW) + module.exports = { WORKFLOW, /**