Skip to content

Commit

Permalink
update: use parallel limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanceYu committed Dec 1, 2024
1 parent 20903dc commit a77c044
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

/**
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions server/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const tags = fs.readJsonSync(TAGS_PATH)
*/
const WORKFLOW = !!process.env.WORKFLOW

console.log('WORKFLOW:', WORKFLOW)

module.exports = {
WORKFLOW,
/**
Expand Down

0 comments on commit a77c044

Please sign in to comment.