modify plugin name
This commit is contained in:
@@ -7,6 +7,7 @@ use Kiri;
|
|||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Di\ContainerInterface;
|
use Kiri\Di\ContainerInterface;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
|
use Kiri\Server\Events\OnShutdown;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
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 \Kiri\Server\Config $config
|
||||||
* @param int $daemon
|
* @param int $daemon
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Kiri\Di\ContainerInterface;
|
|||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Server\Constant;
|
use Kiri\Server\Constant;
|
||||||
|
use Kiri\Server\Events\OnShutdown;
|
||||||
use Kiri\Server\Events\OnWorkerStart;
|
use Kiri\Server\Events\OnWorkerStart;
|
||||||
use Kiri\Server\Events\OnWorkerStop;
|
use Kiri\Server\Events\OnWorkerStop;
|
||||||
use Kiri\Server\ServerInterface;
|
use Kiri\Server\ServerInterface;
|
||||||
@@ -33,6 +34,9 @@ class CoroutineServer implements ServerInterface
|
|||||||
use TraitServer;
|
use TraitServer;
|
||||||
|
|
||||||
|
|
||||||
|
private bool $isShutdown = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Config $config
|
* @param Config $config
|
||||||
* @param ContainerInterface $container
|
* @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
|
* @return void
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
@@ -197,6 +218,10 @@ class CoroutineServer implements ServerInterface
|
|||||||
|
|
||||||
$this->dispatch->dispatch(new OnWorkerStop($server, 0));
|
$this->dispatch->dispatch(new OnWorkerStop($server, 0));
|
||||||
|
|
||||||
|
if ($this->isShutdown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->runServer($server);
|
$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 $customProcess
|
||||||
* @param $system
|
* @param $system
|
||||||
|
|||||||
+1
-1
@@ -204,7 +204,7 @@ class Server extends HttpService
|
|||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->logger->error($exception->getMessage());
|
$this->logger->error($exception->getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
$this->manager->getServer()->shutdown();
|
$this->manager->shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user