Skip to content

Commit

Permalink
feat: 新增启动脚本,应对tinypng策略改成单线程且每次请求间隔5秒
Browse files Browse the repository at this point in the history
  • Loading branch information
libudu committed Jul 10, 2023
1 parent 5ed60cc commit 8180d73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const taskManager = {
process.openStdin();
}
},
maxParallel: 20,
maxParallel: 1,
start: () => {
taskManager.totalCount = taskManager.taskList.length;
const initCount = taskManager.taskList.slice(0, taskManager.maxParallel).length;
Expand Down Expand Up @@ -130,7 +130,7 @@ function fileUpload(img) {
res.on('data', buf => {
let obj = JSON.parse(buf.toString());
if (obj.error) {
console.log(`[${img}]:压缩失败!报错:${obj.message}`);
console.log(`[${img}]:压缩失败!报错:${obj.message}`, (new Date()).toLocaleTimeString());
taskManager.taskFinish();
} else {
fileUpdate(img, obj);
Expand Down Expand Up @@ -170,7 +170,7 @@ function fileUpdate(imgpath, obj) {
obj.output.size
},优化比例-${obj.output.ratio}。剩余任务${taskManager.taskList.length}。`
);
taskManager.taskFinish();
setTimeout(taskManager.taskFinish, 5000)
});
});
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"super-tinypng": "./index.js"
},
"scripts": {
"start": "node index.js",
"build": "pkg -t node14-win index.js ",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down

0 comments on commit 8180d73

Please sign in to comment.