Skip to content

Commit

Permalink
[1.x] Fixes Octane's process output not being flushed (#428)
Browse files Browse the repository at this point in the history
* Fixes issue where `php://temp` may be full

* Update InteractsWithServers.php

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
nunomaduro and taylorotwell authored Nov 29, 2021
1 parent 56c357d commit 0dc6539
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/Commands/Concerns/InteractsWithServers.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ protected function writeServerRunningMessage()
]);
}

/**
* Retrieve the given server output and flush it.
*
* @return array
*/
protected function getServerOutput($server)
{
return tap([
$server->getIncrementalOutput(),
$server->getIncrementalErrorOutput(),
], fn () => $server->clearOutput()->clearErrorOutput());
}

/**
* Returns the list of signals to subscribe.
*
Expand Down
6 changes: 4 additions & 2 deletions src/Commands/StartRoadRunnerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ protected function rpcPort()
*/
protected function writeServerOutput($server)
{
Str::of($server->getIncrementalOutput())
[$output, $errorOutput] = $this->getServerOutput($server);

Str::of($output)
->explode("\n")
->filter()
->each(function ($output) {
Expand Down Expand Up @@ -210,7 +212,7 @@ protected function writeServerOutput($server)
}
});

Str::of($server->getIncrementalErrorOutput())
Str::of($errorOutput)
->explode("\n")
->filter()
->each(function ($output) {
Expand Down
6 changes: 4 additions & 2 deletions src/Commands/StartSwooleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,17 @@ protected function taskWorkerCount(SwooleExtension $extension)
*/
protected function writeServerOutput($server)
{
Str::of($server->getIncrementalOutput())
[$output, $errorOutput] = $this->getServerOutput($server);

Str::of($output)
->explode("\n")
->filter()
->each(fn ($output) => is_array($stream = json_decode($output, true))
? $this->handleStream($stream)
: $this->info($output)
);

Str::of($server->getIncrementalErrorOutput())
Str::of($errorOutput)
->explode("\n")
->filter()
->groupBy(fn ($output) => $output)
Expand Down

0 comments on commit 0dc6539

Please sign in to comment.