修改任务队列重新设置并发

This commit is contained in:
whyour 2023-10-08 22:18:54 +08:00
parent aac109621a
commit c35cfba8b0

View File

@ -18,6 +18,7 @@ class TaskLimit {
constructor() { constructor() {
this.setCustomLimit(); this.setCustomLimit();
this.handleEvents();
} }
private handleEvents() { private handleEvents() {
@ -55,8 +56,7 @@ class TaskLimit {
public async setCustomLimit(limit?: number) { public async setCustomLimit(limit?: number) {
if (limit) { if (limit) {
this.cronLimit = new PQueue({ concurrency: limit });; this.cronLimit.concurrency = limit;
this.handleEvents();
return; return;
} }
await AuthModel.sync(); await AuthModel.sync();
@ -64,8 +64,7 @@ class TaskLimit {
where: { type: AuthDataType.systemConfig }, where: { type: AuthDataType.systemConfig },
}); });
if (doc?.info?.cronConcurrency) { if (doc?.info?.cronConcurrency) {
this.cronLimit = new PQueue({ concurrency: doc?.info?.cronConcurrency }); this.cronLimit.concurrency = doc.info.cronConcurrency;
this.handleEvents();
} }
} }