From 68b996535da5182f68602ab782a3490b732d540c Mon Sep 17 00:00:00 2001 From: Christopher Hase Date: Fri, 28 Mar 2025 13:21:30 +0100 Subject: [PATCH] schedule next run part 2 --- broker.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/broker.ts b/broker.ts index a9218c2..83b8336 100644 --- a/broker.ts +++ b/broker.ts @@ -37,6 +37,8 @@ exec('iching divine', (error, stdout, stderr) => { if (config == undefined) { config = loadConfig(); + } else { //TODO: JUST FOR DEBUGGING + console.log(`Config already read...`); } console.log(config.daysInterval, config.timeOfDay); @@ -53,11 +55,13 @@ exec('iching divine', (error, stdout, stderr) => { // Funktion, um die Konfiguration zu laden function loadConfig(): Config { + + console.log(`Load Config`); + const data = fs.readFileSync('config.json', 'utf-8'); return JSON.parse(data); } - // Send E-Mail async function sendEmail(content: string) { try { @@ -89,7 +93,7 @@ async function sleep() { function calculateNextRunDate(daysInterval: number, timeOfDay: string): Date { const currentDate = new Date(); - // Splitte die Uhrzeit in Stunden und Minuten + /*// Splitte die Uhrzeit in Stunden und Minuten const [hours, minutes] = timeOfDay.split(':').map(Number); // Berechne das Datum für die nächste Ausführung @@ -103,6 +107,10 @@ function calculateNextRunDate(daysInterval: number, timeOfDay: string): Date { // Berechne das Datum für den nächsten Ausführungszeitpunkt unter Berücksichtigung von X Tagen currentDate.setDate(currentDate.getDate() + daysInterval); + return currentDate;*/ + + currentDate.setMinutes(currentDate.getMinutes() + 1); //TODO: JUST FOR DEBUGGING!!! + return currentDate; }