From 4fef4a7dd41b98f37e8d40e2702c76d3855475aa Mon Sep 17 00:00:00 2001 From: Ingo Ratsdorf Date: Sat, 27 Sep 2025 16:52:50 +1200 Subject: [PATCH] make scheduler setup more robust against wrong scheduling is the schedule input is incorrect, an error message is logged and the plugin will NOT run. Creating a dummy schedule would throw the system out of balance as there's the danger of schedules running out of sync. --- server/initialise.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/server/initialise.py b/server/initialise.py index 5bd8aa3d..5fc8c0ed 100755 --- a/server/initialise.py +++ b/server/initialise.py @@ -368,8 +368,19 @@ def importConfigs (pm, db, all_plugins): # mylog('verbose', [f"[Config] pref {plugin["unique_prefix"]} run_val {run_val} run_sch {run_sch} "]) if run_val == 'schedule': - newSchedule = Cron(run_sch).schedule(start_date=datetime.datetime.now(conf.tz)) - conf.mySchedules.append(schedule_class(plugin["unique_prefix"], newSchedule, newSchedule.next(), False)) + newSchedule = None + try: + newSchedule = Cron(run_sch).schedule(start_date=datetime.datetime.now(conf.tz)) + if (newSchedule is not None): + conf.mySchedules.append(schedule_class(plugin["unique_prefix"], newSchedule, newSchedule.next(), False)) + else: + raise(ValueError("Invalid schedule")) + except ValueError as e: + mylog('none', [f"[Config] [ERROR] Invalid schedule '{run_sch}' for plugin '{plugin['unique_prefix']}'. Error: {e}."]) + except Exception as e: + mylog('none', [f"[Config] [ERROR] Could not set schedule '{run_sch}' for plugin '{plugin['unique_prefix']}'. Error: {e}."]) + + # mylog('verbose', [f"[Config] conf.mySchedules {conf.mySchedules}"])