From 5ad08791ea3f6ff924939ab6a2a15b852a29fc10 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 14 May 2024 12:52:01 +0200 Subject: [PATCH] chore: Skip scheduled tasks if application or service is not running --- app/Console/Kernel.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 89d679a47..d67a26720 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -138,7 +138,18 @@ private function check_scheduled_tasks($schedule) $scheduled_task->delete(); continue; } - + if ($application) { + if (str($application->status)->contains('running') === false) { + ray('application not running, skipping'); + continue; + } + } + if ($service) { + if (str($service->status)->contains('running') === false) { + ray('service not running, skipping'); + continue; + } + } if (isset(VALID_CRON_STRINGS[$scheduled_task->frequency])) { $scheduled_task->frequency = VALID_CRON_STRINGS[$scheduled_task->frequency]; }