From 2d97c3fe9249ef56d133d0565f3d6e571855f8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 4 Jan 2021 17:16:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/DatabasesProviders.php | 1 + HttpServer/Events/OnWorkerStart.php | 1 + System/Cache/Redis.php | 1 + System/Event.php | 1 + 4 files changed, 4 insertions(+) diff --git a/Database/DatabasesProviders.php b/Database/DatabasesProviders.php index a82d315b..f171aa42 100644 --- a/Database/DatabasesProviders.php +++ b/Database/DatabasesProviders.php @@ -30,6 +30,7 @@ class DatabasesProviders extends Providers $event = Snowflake::app()->getEvent(); $event->on(Event::SERVER_WORKER_START, [$this, 'createPool']); + $event->on(Event::SERVER_TASK_START, [$this, 'createPool']); } diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index d5268a90..766fe4a4 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -35,6 +35,7 @@ class OnWorkerStart extends Callback swoole_set_process_name($get_name); } if ($worker_id >= $server->setting['worker_num']) { + fire(Event::SERVER_TASK_START); return; } Snowflake::setWorkerId($server->worker_pid); diff --git a/System/Cache/Redis.php b/System/Cache/Redis.php index 667311c8..7115c0e6 100644 --- a/System/Cache/Redis.php +++ b/System/Cache/Redis.php @@ -39,6 +39,7 @@ class Redis extends Component $event->on(Event::RELEASE_ALL, [$this, 'destroy']); $event->on(Event::EVENT_AFTER_REQUEST, [$this, 'release']); $event->on(Event::SERVER_WORKER_START, [$this, 'createPool']); + $event->on(Event::SERVER_TASK_START, [$this, 'createPool']); } diff --git a/System/Event.php b/System/Event.php index 2992f503..31907f87 100644 --- a/System/Event.php +++ b/System/Event.php @@ -43,6 +43,7 @@ class Event extends BaseObject const SERVER_MANAGER_STOP = 'SERVER:EVENT:MANAGER:START'; const SERVER_WORKER_STOP = 'SERVER:EVENT:WORKER:STOP'; const SERVER_WORKER_START = 'SERVER:EVENT:WORKER:START'; + const SERVER_TASK_START = 'SERVER:EVENT:TASK:START'; const SERVER_WORKER_EXIT = 'SERVER:EVENT:WORKER:EXIT'; const SERVER_WORKER_ERROR = 'SERVER:EVENT:WORKER:ERROR'; const SERVER_SHUTDOWN = 'SERVER:EVENT:SHUTDOWN';