From 7216376743551dd10892d25a35cf3bfaaab536a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 16 Apr 2021 15:05:08 +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 --- Annotation/LocalService.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Annotation/LocalService.php b/Annotation/LocalService.php index 58667d92..8bacb11e 100644 --- a/Annotation/LocalService.php +++ b/Annotation/LocalService.php @@ -5,8 +5,8 @@ namespace Annotation; use Exception; -use Snowflake\Snowflake; use Snowflake\Event; +use Snowflake\Snowflake; /** * Class LocalService @@ -42,12 +42,16 @@ use Snowflake\Event; Snowflake::set($this->service, $class); if ($this->async_reload === true) { $event = Snowflake::app()->getEvent(); - $event->on(Event::SERVER_WORKER_EXIT, function () { - Snowflake::app()->remove($this->service); - }); + $event->on(Event::SERVER_WORKER_EXIT, [$this, 'clear']); } return parent::execute($handler); // TODO: Change the autogenerated stub } + + public function clear() + { + Snowflake::app()->remove($this->service); + } + }