Skip to content

Commit 6719723

Browse files
committed
Resolve #22
Add listing for all units
1 parent aa597cf commit 6719723

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Command/SymfonyCommand.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@
1414
*/
1515
class SymfonyCommand implements CommandInterface
1616
{
17+
/**
18+
* List of valid exit codes of systemctl commands.
19+
* When systemctl is-active is checked on a non active unit, we receive exit code 3
20+
*/
21+
private const VALID_EXITCODES = [0, 3];
22+
1723
/** @var Process */
1824
private $process;
1925

26+
/**
27+
* @param Process $process
28+
*/
2029
public function __construct(Process $process)
2130
{
2231
$this->process = $process;
@@ -45,7 +54,9 @@ public function run(): CommandInterface
4554
{
4655
$this->process->run();
4756

48-
if (!$this->process->isSuccessful()) {
57+
$exitCode = $this->process->getExitCode();
58+
59+
if (!\in_array((int)$exitCode, self::VALID_EXITCODES, true)) {
4960
throw new CommandFailedException($this->process->getErrorOutput());
5061
}
5162

src/SystemCtl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static function setAssetPath(string $assetPath): void
123123
*/
124124
public function listUnits(?string $unitPrefix = null, array $unitTypes = self::SUPPORTED_UNITS): array
125125
{
126-
$commands = ['list-units'];
126+
$commands = ['--all', 'list-units'];
127127

128128
if ($unitPrefix) {
129129
$commands[] = $unitPrefix;

0 commit comments

Comments
 (0)