diff --git a/testing/src/Environment.php b/testing/src/Environment.php index cd65655c..f8eb5f3b 100644 --- a/testing/src/Environment.php +++ b/testing/src/Environment.php @@ -126,7 +126,7 @@ public function startTemporalServer( $this->temporalServerProcess->start(); $deadline = \microtime(true) + (float) $commandTimeout; - while (!$temporalStarted && \microtime(true) < $deadline) { + while ($this->temporalServerProcess->isRunning() && !$temporalStarted && \microtime(true) < $deadline) { \usleep(10_000); $check = new Process([ $this->systemInfo->temporalCliExecutable, @@ -205,7 +205,7 @@ public function startRoadRunner(?array $rrCommand = null, int $commandTimeout = } $this->roadRunnerProcess = new Process( - command: $rrCommand ?? [$this->systemInfo->rrExecutable, 'serve'], + command: $rrCommand ?? [$this->systemInfo->rrExecutable, 'serve', '-c', $configFile], env: $envs, ); $this->roadRunnerProcess->setTimeout($commandTimeout); @@ -217,16 +217,16 @@ public function startRoadRunner(?array $rrCommand = null, int $commandTimeout = // wait for roadrunner to start $deadline = \microtime(true) + (float) $commandTimeout; - while (!$roadRunnerStarted && \microtime(true) < $deadline) { + while ($this->roadRunnerProcess->isRunning() && !$roadRunnerStarted && \microtime(true) < $deadline) { \usleep(10_000); - $check = new Process([$this->systemInfo->rrExecutable, 'workers', '-c', $configFile]); + $check = new Process(array_map(static fn ($arg) => $arg === 'serve' ? 'workers' : $arg, $rrCommand)); $check->run(); if (\str_contains($check->getOutput(), 'Workers of')) { $roadRunnerStarted = true; } } - if (!$roadRunnerStarted) { + if (!$roadRunnerStarted || !$this->roadRunnerProcess->isRunning()) { $this->io->error(\sprintf( 'Failed to start until RoadRunner is ready. Status: "%s". Stderr: "%s". Stdout: "%s".', $this->roadRunnerProcess->getStatus(),