Skip to content

Commit 5750fe9

Browse files
author
Paramtamtam
committed
Fix for termination request handling
1 parent caf47ee commit 5750fe9

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].
66

7+
## v4.0.1
8+
9+
### Fixed
10+
11+
- Termination request handling (safe loop breaking)
12+
713
## v4.0.0
814

915
### Added

src/Worker.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Spiral\RoadRunnerLaravel;
66

7+
use Psr\Http\Message\ServerRequestInterface;
78
use Throwable;
89
use Illuminate\Http\Request;
910
use InvalidArgumentException;
@@ -51,6 +52,10 @@ public function start(WorkerOptionsInterface $options): void
5152
$this->fireEvent($app, new Events\BeforeLoopStartedEvent($app));
5253

5354
while ($req = $psr7_worker->waitRequest()) {
55+
if (!($req instanceof ServerRequestInterface)) { // termination request received
56+
break;
57+
}
58+
5459
$responded = false;
5560

5661
if ($options->getRefreshApp()) {

tests/Feature/WorkerTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ protected function createConfigFile(string $where, string $relay_type): string
100100
static:
101101
dir: "{$static_dir}"
102102
forbid: [".php"]
103-
104-
endure:
105-
log_level: warning # do NOT comment this lines - test will fails otherwise O_o
106103
EOF;
107104

108105
$wrote = (new Filesystem())->put($config_file_path, $content, true);
@@ -148,7 +145,9 @@ public function testServerStartingUsingDifferentRelayTypes(): void
148145
)]);
149146
$http_client = new \GuzzleHttp\Client(['base_uri' => 'http://127.0.0.1:22622']);
150147

151-
// $rr_proc->disableOutput(); // @todo: This will fix `endure.log_level` problem, thx 2 @jetexe
148+
// is required for preventing child process blocking, thx @jetexe
149+
// more info: <https://www.php.net/manual/ru/function.proc-open.php#38870>
150+
$rr_proc->disableOutput();
152151

153152
try {
154153
// https://symfony.com/doc/current/components/process.html#running-processes-asynchronously

0 commit comments

Comments
 (0)