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';