Skip to content

Commit

Permalink
make Log when script was fail
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed Sep 26, 2024
1 parent dd9a641 commit 254972c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/Jobs/RunMdaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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(),
];

Expand Down

0 comments on commit 254972c

Please sign in to comment.