File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1414 */
1515class 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
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments