From 6baa4ada7729e6c5a52a457625a30bb82b840e20 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Tue, 24 Oct 2023 11:03:57 +0200 Subject: [PATCH] Don't crash when failing to connect to the database --- application/clicommands/ScheduleCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/application/clicommands/ScheduleCommand.php b/application/clicommands/ScheduleCommand.php index c52e0921..a898db4f 100644 --- a/application/clicommands/ScheduleCommand.php +++ b/application/clicommands/ScheduleCommand.php @@ -37,7 +37,13 @@ public function runAction() // Check for configuration changes every 5 minutes to make sure new jobs are scheduled, updated and deleted // jobs are cancelled. $watchdog = function () use (&$watchdog, $scheduler, &$runningSchedules) { - $schedules = $this->fetchSchedules(); + $schedules = []; + try { + $schedules = $this->fetchSchedules(); + } catch (Throwable $err) { + Logger::error('Failed to fetch report schedules from the database: %s', $err); + } + $outdated = array_diff_key($runningSchedules, $schedules); foreach ($outdated as $schedule) { Logger::info(