modify plugin name

This commit is contained in:
2022-06-20 18:14:25 +08:00
parent b20c8fc5a3
commit 2a5b7d1cac
4 changed files with 56 additions and 2 deletions
+26 -1
View File
@@ -7,6 +7,7 @@ use Kiri\Di\ContainerInterface;
use Kiri\Events\EventDispatch;
use Kiri\Exception\ConfigException;
use Kiri\Server\Constant;
use Kiri\Server\Events\OnShutdown;
use Kiri\Server\Events\OnWorkerStart;
use Kiri\Server\Events\OnWorkerStop;
use Kiri\Server\ServerInterface;
@@ -33,6 +34,9 @@ class CoroutineServer implements ServerInterface
use TraitServer;
private bool $isShutdown = false;
/**
* @param Config $config
* @param ContainerInterface $container
@@ -164,6 +168,23 @@ class CoroutineServer implements ServerInterface
}
/**
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws \ReflectionException
*/
public function shutdown(): void
{
$this->isShutdown = true;
$this->processManager->shutdown();
foreach ($this->servers as $server) {
$server->shutdown();
}
$this->dispatch->dispatch(new OnShutdown());
}
/**
* @return void
* @throws ConfigException
@@ -195,7 +216,11 @@ class CoroutineServer implements ServerInterface
$server->start();
$this->dispatch->dispatch(new OnWorkerStop($server,0));
$this->dispatch->dispatch(new OnWorkerStop($server, 0));
if ($this->isShutdown) {
return;
}
$this->runServer($server);
}