From 6bf69dfa087189c664f4894bcb68c5425764e50c Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 2 Aug 2022 16:31:11 +0100 Subject: [PATCH 1/2] Adds support for Swoole 5 --- src/Swoole/Handlers/OnServerStart.php | 5 +++-- src/Swoole/Handlers/OnWorkerStart.php | 7 +------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Swoole/Handlers/OnServerStart.php b/src/Swoole/Handlers/OnServerStart.php index 5cd1f6dfe..64943571d 100644 --- a/src/Swoole/Handlers/OnServerStart.php +++ b/src/Swoole/Handlers/OnServerStart.php @@ -5,6 +5,7 @@ use Laravel\Octane\Swoole\Actions\EnsureRequestsDontExceedMaxExecutionTime; use Laravel\Octane\Swoole\ServerStateFile; use Laravel\Octane\Swoole\SwooleExtension; +use Swoole\Timer; class OnServerStart { @@ -37,13 +38,13 @@ public function __invoke($server) } if ($this->shouldTick) { - $server->tick(1000, function () use ($server) { + Timer::tick(1000, function () use ($server) { $server->task('octane-tick'); }); } if ($this->maxExecutionTime > 0) { - $server->tick(1000, function () use ($server) { + Timer::tick(1000, function () use ($server) { (new EnsureRequestsDontExceedMaxExecutionTime( $this->extension, $this->timerTable, $this->maxExecutionTime, $server ))(); diff --git a/src/Swoole/Handlers/OnWorkerStart.php b/src/Swoole/Handlers/OnWorkerStart.php index fc6d41152..be2425547 100644 --- a/src/Swoole/Handlers/OnWorkerStart.php +++ b/src/Swoole/Handlers/OnWorkerStart.php @@ -83,12 +83,7 @@ protected function bootWorker($server) */ protected function dispatchServerTickTaskEverySecond($server) { - // if ($this->workerState->workerId === 0 && - // ($this->serverState['octaneConfig']['tick'] ?? true)) { - // $this->workerState->tickTimerId = $server->tick(1000, function () use ($server) { - // $server->task('octane-tick'); - // }); - // } + // .. } /** From eda70de8ea94225478e027bd7098afd15f65b946 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 2 Aug 2022 10:34:35 -0500 Subject: [PATCH 2/2] Update OnWorkerStart.php --- src/Swoole/Handlers/OnWorkerStart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Swoole/Handlers/OnWorkerStart.php b/src/Swoole/Handlers/OnWorkerStart.php index be2425547..4d27b0356 100644 --- a/src/Swoole/Handlers/OnWorkerStart.php +++ b/src/Swoole/Handlers/OnWorkerStart.php @@ -83,7 +83,7 @@ protected function bootWorker($server) */ protected function dispatchServerTickTaskEverySecond($server) { - // .. + // ... } /**