From e4e8f76db1061a246fd01345669c64badc9fe4ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 7 Apr 2021 10:11:12 +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 --- System/Process/ServerInotify.php | 71 +++++++------------------------- 1 file changed, 16 insertions(+), 55 deletions(-) diff --git a/System/Process/ServerInotify.php b/System/Process/ServerInotify.php index 5bde5b52..697b1a36 100644 --- a/System/Process/ServerInotify.php +++ b/System/Process/ServerInotify.php @@ -35,29 +35,6 @@ class ServerInotify extends Process private int $int = -1; - /** - * @throws Exception - */ - private function loadAnnotation() - { - $annotation = Snowflake::app()->getAnnotation(); - $annotation->read(directory('app'), 'App'); - } - - - /** - * @param $workerId - * @throws Exception - */ - public function getLoader($workerId) - { - $annotation = Snowflake::app()->getAnnotation(); - - $server = Snowflake::app()->getSwoole(); - $server->sendMessage($annotation->getLoader(), $workerId); - } - - /** * @param \Swoole\Process $process * @throws Exception @@ -67,17 +44,6 @@ class ServerInotify extends Process set_error_handler([$this, 'onErrorHandler']); $this->dirs = Config::get('inotify', [APP_PATH]); - Coroutine\go(function () use ($process) { - $workerId = $process->read(3); - - $annotation = Snowflake::app()->getAnnotation(); - - $server = Snowflake::app()->getSwoole(); - $server->sendMessage($annotation->getLoader(),(int) $workerId); - }); - - $this->loadAnnotation(); - if (extension_loaded('inotify')) { $this->inotify = inotify_init(); $this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE; @@ -231,16 +197,14 @@ class ServerInotify extends Process $this->isReloading = true; $this->trigger_reload(); - $this->exit(0); - -// $this->clearWatch(); -// foreach ($this->dirs as $root) { -// $this->watch($root); -// } -// $this->int = -1; -// $this->isReloading = FALSE; -// $this->isReloadingOut = FALSE; -// $this->md5Map = []; + $this->clearWatch(); + foreach ($this->dirs as $root) { + $this->watch($root); + } + $this->int = -1; + $this->isReloading = FALSE; + $this->isReloadingOut = FALSE; + $this->md5Map = []; } /** @@ -251,17 +215,14 @@ class ServerInotify extends Process $this->isReloading = true; $this->trigger_reload(); - $this->exit(0); -// -// -// $this->int = -1; -// -// $this->loadDirs(); -// -// $this->isReloading = FALSE; -// $this->isReloadingOut = FALSE; -// -// $this->tick(); + $this->int = -1; + + $this->loadDirs(); + + $this->isReloading = FALSE; + $this->isReloadingOut = FALSE; + + $this->tick(); }