From 65c3deffd7f7db701f6543ab05f44e954d2e35b5 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 8 Aug 2023 00:11:07 +0300 Subject: [PATCH 1/3] Update worker.md - fix worker sample We need to avoid infinity cycle --- docs/en/php/worker.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/en/php/worker.md b/docs/en/php/worker.md index 0571b42c..4cdcffd3 100644 --- a/docs/en/php/worker.md +++ b/docs/en/php/worker.md @@ -40,7 +40,6 @@ use Nyholm\Psr7\Factory\Psr17Factory; use Spiral\RoadRunner\Worker; use Spiral\RoadRunner\Http\PSR7Worker; - // Create new RoadRunner worker from global environment $worker = Worker::create(); @@ -49,7 +48,7 @@ $factory = new Psr17Factory(); $psr7 = new PSR7Worker($worker, $factory, $factory, $factory); -while (true) { +do { try { $request = $psr7->waitRequest(); } catch (\Throwable $e) { @@ -81,7 +80,7 @@ while (true) { // of the request failed. $psr7->getWorker()->error((string)$e); } -} +} while (isset($request)); ``` This worker expects communication with the RoadRunner server over standard pipes. @@ -232,4 +231,4 @@ interacting with RoadRunner. ## What's Next? -1. [Plugins — Server](../plugins/server.md) - Read more about RoadRunner server plugin. \ No newline at end of file +1. [Plugins — Server](../plugins/server.md) - Read more about RoadRunner server plugin. From 9ea89127b1e81d26d15f9a0edb99cc85c38a319a Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 8 Aug 2023 00:30:17 +0300 Subject: [PATCH 2/3] Update worker.md --- docs/en/php/worker.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/en/php/worker.md b/docs/en/php/worker.md index 4cdcffd3..f9938baa 100644 --- a/docs/en/php/worker.md +++ b/docs/en/php/worker.md @@ -51,6 +51,9 @@ $psr7 = new PSR7Worker($worker, $factory, $factory, $factory); do { try { $request = $psr7->waitRequest(); + if ($request === null) { + continue; + } } catch (\Throwable $e) { // Although the PSR-17 specification clearly states that there can be // no exceptions when creating a request, however, some implementations From ae9b732e1fca8e4174dbb182df7a017a4537b193 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 8 Aug 2023 00:32:34 +0300 Subject: [PATCH 3/3] Update worker.md --- docs/en/php/worker.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/php/worker.md b/docs/en/php/worker.md index f9938baa..0bf0a33b 100644 --- a/docs/en/php/worker.md +++ b/docs/en/php/worker.md @@ -52,7 +52,7 @@ do { try { $request = $psr7->waitRequest(); if ($request === null) { - continue; + break; } } catch (\Throwable $e) { // Although the PSR-17 specification clearly states that there can be