From 03715ceaa4c92d51561196f5352fcf146e05b31d Mon Sep 17 00:00:00 2001 From: Oliver Sand Date: Tue, 6 Jul 2021 16:37:01 +0200 Subject: [PATCH] Add comment and remove initial run Signed-off-by: Oliver Sand --- plugins/search-backend-node/src/Scheduler.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/search-backend-node/src/Scheduler.ts b/plugins/search-backend-node/src/Scheduler.ts index 56cefc52df..3e356aa6aa 100644 --- a/plugins/search-backend-node/src/Scheduler.ts +++ b/plugins/search-backend-node/src/Scheduler.ts @@ -37,8 +37,9 @@ export class Scheduler { } /** - * Adds each task and interval to the schedule - * + * Adds each task and interval to the schedule. + * When running the tasks, the scheduler waits at least for the time specified + * in the interval once the task was completed, before running it again. */ addToSchedule(task: Function, interval: number) { if (this.runningTasks.length) { @@ -55,8 +56,6 @@ export class Scheduler { start() { this.logger.info('Starting all scheduled search tasks.'); this.schedule.forEach(({ task, interval }) => { - // Fire the task immediately, then schedule it. - task(); this.runningTasks.push(runPeriodically(() => task(), interval)); }); }