modify plugin name
This commit is contained in:
@@ -7,6 +7,7 @@ use Kiri;
|
||||
use Kiri\Abstracts\Config;
|
||||
use Kiri\Di\ContainerInterface;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri\Server\Events\OnShutdown;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -81,6 +82,20 @@ class AsyncServer implements ServerInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function shutdown(): void
|
||||
{
|
||||
$this->server->shutdown();
|
||||
|
||||
$this->dispatch->dispatch(new OnShutdown());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \Kiri\Server\Config $config
|
||||
* @param int $daemon
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,20 @@ class ProcessManager
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function shutdown(): void
|
||||
{
|
||||
foreach ($this->_process as $process) {
|
||||
if (!$process instanceof Process) {
|
||||
continue;
|
||||
}
|
||||
$process->exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $customProcess
|
||||
* @param $system
|
||||
|
||||
Reference in New Issue
Block a user