Files
kiri-http-server/Handler/OnServerManager.php
T
2022-06-23 01:18:19 +08:00

59 lines
1.3 KiB
PHP

<?php
namespace Kiri\Server\Handler;
use Kiri;
use Kiri\Annotation\Inject;
use Kiri\Events\EventDispatch;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use ReflectionException;
use Kiri\Server\Abstracts\Server;
use Kiri\Exception\ConfigException;
use Kiri\Server\Events\OnManagerStart;
use Kiri\Server\Events\OnManagerStop;
/**
* Class OnServerManager
* @package Server\Manager
*/
class OnServerManager extends Server
{
/**
* @param EventDispatch $dispatch
* @throws \Exception
*/
public function __construct(public EventDispatch $dispatch)
{
parent::__construct();
}
/**
* @param \Swoole\Server $server
* @throws ConfigException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function onManagerStart(\Swoole\Server $server)
{
Kiri::setProcessName(sprintf('manger process[%d]', $server->manager_pid));
$this->dispatch->dispatch(new OnManagerStart($server));
}
/**
* @param \Swoole\Server $server
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function onManagerStop(\Swoole\Server $server)
{
$this->dispatch->dispatch(new OnManagerStop($server));
}
}