修复任务详情日志列表卡顿

This commit is contained in:
whyour
2023-07-27 23:15:48 +08:00
parent 6832cb4e22
commit 39bfd39559
16 changed files with 71 additions and 32 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ export class Crontab {
constructor(options: Crontab) {
this.name = options.name;
this.command = options.command;
this.command = options.command.trim();
this.schedule = options.schedule;
this.saved = options.saved;
this.id = options.id;
+7 -3
View File
@@ -17,7 +17,7 @@ const addCron = (
scheduleStacks.get(id)?.cancel();
}
let cmdStr = command;
let cmdStr = command.trim();
if (!cmdStr.startsWith(TASK_PREFIX) && !cmdStr.startsWith(QL_PREFIX)) {
cmdStr = `${TASK_PREFIX}${cmdStr}`;
}
@@ -25,8 +25,12 @@ const addCron = (
scheduleStacks.set(
id,
nodeSchedule.scheduleJob(id, schedule, async () => {
Logger.silly(`当前时间: ${dayjs().format('YYYY-MM-DD HH:mm:ss')},运行命令: ${cmdStr}`);
runCron(`ID=${id} ${cmdStr}`)
Logger.info(
`当前时间: ${dayjs().format(
'YYYY-MM-DD HH:mm:ss',
)},运行命令: ${cmdStr}`,
);
runCron(`ID=${id} ${cmdStr}`);
}),
);
}
+5 -4
View File
@@ -507,13 +507,14 @@ export default class CronService {
}
private make_command(tab: Crontab) {
let command = tab.command.trim();
if (
!tab.command.startsWith(TASK_PREFIX) &&
!tab.command.startsWith(QL_PREFIX)
!command.startsWith(TASK_PREFIX) &&
!command.startsWith(QL_PREFIX)
) {
tab.command = `${TASK_PREFIX}${tab.command}`;
command = `${TASK_PREFIX}${tab.command}`;
}
const crontab_job_string = `ID=${tab.id} ${tab.command}`;
const crontab_job_string = `ID=${tab.id} ${command}`;
return crontab_job_string;
}
+1
View File
@@ -16,6 +16,7 @@ class TaskLimit {
this.cpuLimit = pLimit(limit);
return;
}
await AuthModel.sync();
const doc = await AuthModel.findOne({ where: { type: AuthDataType.systemConfig } });
if (doc?.info?.cronConcurrency) {
this.cpuLimit = pLimit(doc?.info?.cronConcurrency);