Browse Source

cron command now fails if any job has failed

Olivier Massot 3 years ago
parent
commit
f83564f622
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/Commands/CronCommand.php

+ 4 - 2
src/Commands/CronCommand.php

@@ -131,11 +131,13 @@ class CronCommand extends Command
             implode(', ', array_map(static function($job) { return $job->name(); }, $jobs))
         );
 
+        $results = [];
+
         foreach ($jobs as $job) {
-            $this->runJob($job, $preview);
+            $results[] = $this->runJob($job, $preview);
         }
 
-        return Command::SUCCESS;
+        return max($results); // If there is one failure result, the whole command is shown as a failure too
     }
 
     /**