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 Exception;
use Snowflake\Snowflake;
use Snowflake\Event; use Snowflake\Event;
use Snowflake\Snowflake;
/** /**
* Class LocalService * Class LocalService
@@ -42,12 +42,16 @@ use Snowflake\Event;
Snowflake::set($this->service, $class); Snowflake::set($this->service, $class);
if ($this->async_reload === true) { if ($this->async_reload === true) {
$event = Snowflake::app()->getEvent(); $event = Snowflake::app()->getEvent();
$event->on(Event::SERVER_WORKER_EXIT, function () { $event->on(Event::SERVER_WORKER_EXIT, [$this, 'clear']);
Snowflake::app()->remove($this->service);
});
} }
return parent::execute($handler); // TODO: Change the autogenerated stub return parent::execute($handler); // TODO: Change the autogenerated stub
} }
public function clear()
{
Snowflake::app()->remove($this->service);
}
} }