From e8ddd5ba3f7f134066f9c36c1a7eb0568afd5101 Mon Sep 17 00:00:00 2001 From: Jabar Jeremy <24471994+jabahum@users.noreply.github.com> Date: Wed, 19 Jun 2024 19:36:15 +0300 Subject: [PATCH] fix cron job (#8) --- server/lib/modules/cronjobs.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server/lib/modules/cronjobs.js b/server/lib/modules/cronjobs.js index e3b62adc..30bd581d 100644 --- a/server/lib/modules/cronjobs.js +++ b/server/lib/modules/cronjobs.js @@ -5,9 +5,15 @@ const logger = require("../winston"); let patientReprocessing = config.get("cronJobs:patientReprocessing"); +if (typeof patientReprocessing !== 'string') { + throw new TypeError('patientReprocessing must be a string!'); +} + cron.schedule(patientReprocessing, () => { - logger.info("Running cron job for patients reprocessing"); - matchMixin.reprocessPatients().then(() => { - logger.info("Done running cron job for patients reprocessing"); - }); + logger.info("Running cron job for patients reprocessing"); + matchMixin.reprocessPatients().then(() => { + logger.info("Done running cron job for patients reprocessing"); + }).catch((error) => { + logger.error("Error running cron job for patients reprocessing:", error); }); +});