Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 8, 2020
1 parent a8d9204 commit bbddba2
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions src/Illuminate/Console/Scheduling/ScheduleWorkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit bbddba2

Please sign in to comment.