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); + } + }