From 254972c48897f6fa4cdfb52a6934c8435f6819ee Mon Sep 17 00:00:00 2001 From: Artem Otliaguzov Date: Thu, 26 Sep 2024 14:30:29 +0200 Subject: [PATCH] make Log when script was fail --- app/Jobs/RunMdaScript.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Jobs/RunMdaScript.php b/app/Jobs/RunMdaScript.php index bc1555f..8dbde16 100644 --- a/app/Jobs/RunMdaScript.php +++ b/app/Jobs/RunMdaScript.php @@ -67,11 +67,15 @@ public function handle(): void $file = config('storageCfg.mdaConfigFolder').'/'.escapeshellarg($filter).'.xml'; $pipeline = 'main'; $command = 'sh '.escapeshellarg($realScriptPath).' '.$file.' '.$pipeline; - shell_exec($command); + $output = shell_exec($command); + + if ($output === false || str_contains($output, 'ERROR') || str_contains($output, 'WARN')) { + Log::error('Script execution error '.$command.' Message: '.$output); + } } } catch (Exception $e) { - Log::error($e->getMessage()); + Log::error($e); } finally { Cache::restoreLock($lockKey, $this->owner)->release(); @@ -92,7 +96,7 @@ public function middleware(): array $lockKey = 'directory-'.md5($pathToDirectory).'-lock'; return [ - new RateLimited('mda-run-limit'), + // new RateLimited('mda-run-limit'), (new WithoutOverlapping($lockKey))->dontRelease(), ];