修复系统启动执行订阅任务

This commit is contained in:
whyour
2022-05-28 19:56:12 +08:00
parent 8d2c62d6d1
commit f338537ea0
3 changed files with 33 additions and 14 deletions
+14 -1
View File
@@ -106,6 +106,7 @@ export default class ScheduleService {
async createCronTask(
{ id = 0, command, name, schedule = '' }: ScheduleTaskType,
callbacks?: TaskCallbacks,
runImmediately = false,
) {
const _id = this.formatId(id);
this.logger.info(
@@ -122,6 +123,10 @@ export default class ScheduleService {
await this.runTask(command, callbacks);
}),
);
if (runImmediately) {
await this.runTask(command, callbacks);
}
}
async cancelCronTask({ id = 0, name }: ScheduleTaskType) {
@@ -160,9 +165,17 @@ export default class ScheduleService {
},
);
const job = new LongIntervalJob({ ...schedule, runImmediately }, task, _id);
const job = new LongIntervalJob(
{ ...schedule, runImmediately: false },
task,
_id,
);
this.intervalSchedule.addIntervalJob(job);
if (runImmediately) {
await this.runTask(command, callbacks);
}
}
async cancelIntervalTask({ id = 0, name }: ScheduleTaskType) {