Skip to content

Commit 37d7acc

Browse files
author
Andre Ponert
committed
Bugfix: output was not complete ; use variadic arg syntax for groups @related: NEOS-49
1 parent 2f8a706 commit 37d7acc

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

Classes/Command/SupervisorCommandController.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,36 +56,36 @@ public function createCommand(): void
5656
*/
5757
public function startGroupsCommand(): void
5858
{
59-
$groups = $this->getGroups();
60-
array_walk($groups, [$this, 'runSupervisorCommand'], 'start');
59+
$this->runSupervisorCommand('start', ...$this->getGroups());
6160
}
6261

6362
/**
6463
* Stops all programs of configured groups
6564
*/
6665
public function stopGroupsCommand(): void
6766
{
68-
$groups = $this->getGroups();
69-
array_walk($groups, [$this, 'runSupervisorCommand'], 'stop');
67+
$this->runSupervisorCommand('stop', ...$this->getGroups());
7068
}
7169

7270
/**
7371
* Reloads config and starts/stops programs accordingly
7472
*/
7573
public function updateGroupsCommand(): void
7674
{
77-
$groups = $this->getGroups();
78-
array_walk($groups, [$this, 'runSupervisorCommand'], 'update');
75+
$this->runSupervisorCommand('update', ...$this->getGroups());
7976
}
8077

81-
protected function runSupervisorCommand(Model\Group $group, int $key, string $action): bool
78+
protected function runSupervisorCommand(string $action, Model\Group ...$groups): bool
8279
{
8380
$output = [];
84-
$command = sprintf('supervisorctl %s %s%s 2>&1',escapeshellarg($action), escapeshellarg($group->getName()), $action !== 'update' ? ':' : '');
85-
$output = exec($command, $output, $result);
81+
$groupArgs = implode(' ', array_map(function($i){return $i->getName();}, $groups));
82+
$command = sprintf('supervisorctl %s %s%s 2>&1',escapeshellarg($action), escapeshellarg($groupArgs), $action !== 'update' ? ':' : '');
83+
84+
exec($command, $output, $result);
85+
$output = implode("\n", $output);
8686
if ($result !== 0) {
87-
if (count($output) > 0) {
88-
$exceptionMessage = implode(PHP_EOL, $output);
87+
if (!empty($output)) {
88+
$exceptionMessage = $output;
8989
} else {
9090
$exceptionMessage = sprintf('Execution of supervisorctl failed with exit code %d without any further output.', $result);
9191
}

0 commit comments

Comments
 (0)