Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Apr 14, 2020
1 parent bce9659 commit 2878541
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/ProcessInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ public function orphaned()
}

/**
* Get all of the process IDs that Horizon is actively monitoring and that are valid. For master processes "valid"
* means they have child processes (supervisors). For supervisors it means their parent processes (masters) exist.
* Get all of the process IDs that Horizon is actively monitoring and that are valid.
*
* For master processes "valid" means they have child processes (supervisors).
*
* For supervisors "valid" means their parent processes (masters) exist.
*
* @return array
*/
public function validMonitoring()
{
$masters = $this->monitoredMastersWithSupervisors();

$masterNames = array_flip(Arr::pluck($masters, 'name'));

return collect(app(SupervisorRepository::class)->all())
Expand All @@ -79,31 +83,26 @@ public function validMonitoring()
}

/**
* Get data of master processes that have child processes (supervisors) and are monitored by Horizon.
* Get the master processes that have child processes (supervisors) and are monitored by Horizon.
*
* @return array
*/
public function monitoredMastersWithSupervisors()
{
return collect(app(MasterSupervisorRepository::class)->all())->filter(function ($master) {
return ! empty($this->exec->run('pgrep -P '.data_get($master, 'pid')));
})
->values()
->all();
})->values()->all();
}

/**
* Get IDs of all master Horizon processes that don't have any supervisors.
* Get the IDs of all master Horizon processes that don't have any supervisors.
*
* @return array
*/
public function mastersWithoutSupervisors()
{
return collect($this->exec->run('pgrep -f [h]orizon$'))
->filter(function ($pid) {
return empty($this->exec->run('pgrep -P '.$pid));
})
->values()
->all();
return collect($this->exec->run('pgrep -f [h]orizon$'))->filter(function ($pid) {
return empty($this->exec->run('pgrep -P '.$pid));
})->values()->all();
}
}

0 comments on commit 2878541

Please sign in to comment.