Skip to content

Commit

Permalink
Reduce sleep between reading server logs to improve performance for h…
Browse files Browse the repository at this point in the history
…eavy-logging Laravel application using a stderr/stdout logging driver. (#902)

* Add configurable sleep between server output iterations

* Update InteractsWithServers.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
LauJosefsen and taylorotwell authored May 31, 2024
1 parent 2a5028a commit 2c818d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Commands/Concerns/InteractsWithServers.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ protected function runServer($server, $inspector, $type)
$watcher = $this->startServerWatcher();

try {
$usleepBetweenIterations = config('octane.usleep_between_writing_server_output') ??
$_ENV['LARAVEL_OCTANE_USLEEP_BETWEEN_WRITING_SERVER_OUTPUT'] ??
10 * 1000;

while ($server->isRunning()) {
$this->writeServerOutput($server);

Expand All @@ -45,7 +49,7 @@ protected function runServer($server, $inspector, $type)
return 1;
}

usleep(500 * 1000);
usleep($usleepBetweenIterations);
}

$this->writeServerOutput($server);
Expand Down

0 comments on commit 2c818d7

Please sign in to comment.