This commit is contained in:
2021-04-16 15:05:08 +08:00
parent 559685fdf7
commit 7216376743
+8 -4
View File
@@ -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);
}
}