diff --git a/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php b/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php index 10776d093c50..d9af19d87785 100644 --- a/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php +++ b/src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php @@ -32,41 +32,32 @@ public function handle() { $this->info('Schedule worker started successfully.'); - $lastExecutionStartedAt = null; + [$lastExecutionStartedAt, $keyOfLastExecutionWithOutput, $executions] = [null, null, []]; - $keyOfLastExecutionWithOutput = null; + while (true) { + usleep(100 * 1000); - $executions = []; + if (Carbon::now()->second === 0 && + ! Carbon::now()->startOfMinute()->equalTo($lastExecutionStartedAt)) { + $executions[] = $execution = new Process([PHP_BINARY, 'artisan', 'schedule:run']); - while (true) { - if (Carbon::now()->second === 0 && ! Carbon::now()->startOfMinute()->equalTo($lastExecutionStartedAt)) { - $execution = new Process([PHP_BINARY, 'artisan', 'schedule:run']); $execution->start(); - $executions[] = $execution; + $lastExecutionStartedAt = Carbon::now()->startOfMinute(); } foreach ($executions as $key => $execution) { - $incrementalOutput = trim($execution->getIncrementalOutput()); + $output = trim($execution->getIncrementalOutput()). + trim($execution->getIncrementalErrorOutput()); - if (Str::length($incrementalOutput) > 0) { + if (! empty($output)) { if ($key !== $keyOfLastExecutionWithOutput) { $this->info(PHP_EOL.'Execution #'.($key + 1).' output:'); - $keyOfLastExecutionWithOutput = $key; - } - $this->warn($incrementalOutput); - } - - $incrementalErrorOutput = trim($execution->getIncrementalErrorOutput()); - - if (Str::length($incrementalErrorOutput) > 0) { - if ($key !== $keyOfLastExecutionWithOutput) { - $this->info(PHP_EOL.'Execution #'.($key + 1).' output:'); $keyOfLastExecutionWithOutput = $key; } - $this->error(trim($incrementalErrorOutput)); + $this->output->writeln($output); } if (! $execution->isRunning()) {