backend: Update scheduleTask method to be asynchronous and invoke callback immediately
This commit is contained in:
parent
21e959d190
commit
df8c483b34
@ -137,7 +137,7 @@ export class TaskSchedulerService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected scheduleTask(task: IScheduledTask): void {
|
protected async scheduleTask(task: IScheduledTask): Promise<void> {
|
||||||
const { name, type, scheduleOrDelay, callback } = task;
|
const { name, type, scheduleOrDelay, callback } = task;
|
||||||
|
|
||||||
if (this.scheduledTasks.has(name)) {
|
if (this.scheduledTasks.has(name)) {
|
||||||
@ -167,6 +167,8 @@ export class TaskSchedulerService {
|
|||||||
this.logger.error(`Error running cron task "${name}":`, error);
|
this.logger.error(`Error running cron task "${name}":`, error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Start the job immediately
|
||||||
|
await callback();
|
||||||
job.start();
|
job.start();
|
||||||
this.scheduledTasks.set(name, job);
|
this.scheduledTasks.set(name, job);
|
||||||
} else if (type === 'timeout') {
|
} else if (type === 'timeout') {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user