From 3a12ad4db2f174228ba32ec8e30a72a3deaf80de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 1 Sep 2020 15:29:01 +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 --- http-server/Events/Http.php | 3 +-- http-server/Events/Service.php | 3 +-- http-server/Events/WebSocket.php | 3 +-- http-server/ServerManager.php | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/http-server/Events/Http.php b/http-server/Events/Http.php index 1532ec5f..e40d6620 100644 --- a/http-server/Events/Http.php +++ b/http-server/Events/Http.php @@ -37,8 +37,8 @@ class Http extends Server */ public function __construct($application, $host, $port = null, $mode = null, $sock_type = null) { - parent::__construct($host, $port, $mode, $sock_type); $this->application = $application; + parent::__construct($host, $port, $mode, $sock_type); } @@ -55,7 +55,6 @@ class Http extends Server public function set(array $settings, $pool = null, $events = [], $config = []) { parent::set($settings); - Snowflake::get()->set(Pool::class, $pool); ServerManager::set($this, $settings, $this->application, $events, $config); } diff --git a/http-server/Events/Service.php b/http-server/Events/Service.php index dc1847b0..644a5448 100644 --- a/http-server/Events/Service.php +++ b/http-server/Events/Service.php @@ -45,8 +45,8 @@ abstract class Service extends Server */ public function __construct($application, $host, $port = null, $mode = null, $sock_type = null) { - parent::__construct($host, $port, $mode, $sock_type); $this->application = $application; + parent::__construct($host, $port, $mode, $sock_type); } @@ -63,7 +63,6 @@ abstract class Service extends Server public function set(array $settings, $pool = null, $events = [], $config = []) { parent::set($settings); - Snowflake::get()->set(Pool::class, $pool); ServerManager::set($this, $settings, $this->application, $events, $config); } diff --git a/http-server/Events/WebSocket.php b/http-server/Events/WebSocket.php index 22376464..e899844a 100644 --- a/http-server/Events/WebSocket.php +++ b/http-server/Events/WebSocket.php @@ -48,8 +48,8 @@ class WebSocket extends Server */ public function __construct($application, $host, $port = null, $mode = null, $sock_type = null) { - parent::__construct($host, $port, $mode, $sock_type); $this->application = $application; + parent::__construct($host, $port, $mode, $sock_type); } @@ -69,7 +69,6 @@ class WebSocket extends Server $application = Snowflake::get(); $application->set(WebSocket::class, $this); - $application->set(Pool::class, $pool); ServerManager::set($this, $settings, $application, $events, $config); } diff --git a/http-server/ServerManager.php b/http-server/ServerManager.php index e3b65c3d..c3bc5193 100644 --- a/http-server/ServerManager.php +++ b/http-server/ServerManager.php @@ -23,6 +23,7 @@ class ServerManager { try { $application = Snowflake::get(); + $application->set(Pool::class, $pool); if (is_string($process) && class_exists($process)) { return static::createProcess($process, $application, $pool, $workerId); } @@ -69,7 +70,6 @@ class ServerManager */ protected static function createProcess($process, $application, $pool, $workerId) { - $application->set(Pool::class, $pool); $process = new $process($application); $application->debug(sprintf('Worker #%d is running.', $workerId)); return $process->start();