From 843608fae5d12f78ce30e3af70e6bf56a4c8f8fb Mon Sep 17 00:00:00 2001 From: gauquiebart Date: Thu, 27 Jul 2023 09:54:10 +0200 Subject: [PATCH] LPDC-554: When cronjob is scheduled at a faster rate than the job duration itself, a new task run was run (don't in sync code already set the taskIsRunning flag to false ...) --- .gitignore | 3 ++- app.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 55371e5..20335c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -.vscode \ No newline at end of file +.vscode +.idea \ No newline at end of file diff --git a/app.ts b/app.ts index fb6e1d6..ba463db 100644 --- a/app.ts +++ b/app.ts @@ -77,16 +77,20 @@ const consumerJob = new CronJob(CRON_PATTERN, async () => { console.log("Another task is still running"); return; } + taskIsRunning = true; const stream = namedNode(LDES_STREAM); const initialState = await fetchState(stream); const endpoint = LDES_ENDPOINT_VIEW; + console.log("RUN CONSUMER"); + const ldesOptions = { dereferenceMembers: LDES_DEREFERENCE_MEMBERS, disablePolling: RUNONCE, pollingInterval: LDES_POLLING_INTERVAL }; + if (LDES_REQUESTS_PER_MINUTE) { ldesOptions.requestsPerMinute = LDES_REQUESTS_PER_MINUTE; } @@ -131,7 +135,6 @@ const consumerJob = new CronJob(CRON_PATTERN, async () => { } } catch (e) { console.error(e); - } finally { taskIsRunning = false; } });