Files
kiri-http-server/Handler/OnServer.php
T

57 lines
1.2 KiB
PHP
Raw Normal View History

2022-01-09 03:49:02 +08:00
<?php
2022-01-10 11:39:55 +08:00
namespace Kiri\Server\Handler;
2022-01-09 03:49:02 +08:00
use Kiri\Annotation\Inject;
use Kiri\Events\EventDispatch;
use Kiri\Exception\ConfigException;
use ReflectionException;
2022-01-10 11:39:55 +08:00
use Kiri\Server\Abstracts\Server;
use Kiri\Server\Events\OnBeforeShutdown;
use Kiri\Server\Events\OnShutdown;
use Kiri\Server\Events\OnStart;
2022-01-09 03:49:02 +08:00
/**
* Class OnServerDefault
* @package Server\Manager
*/
class OnServer extends Server
{
2022-01-20 19:04:15 +08:00
2022-01-09 03:49:02 +08:00
/**
* @param \Swoole\Server $server
* @throws ConfigException
* @throws ReflectionException
*/
public function onStart(\Swoole\Server $server)
{
$this->setProcessName(sprintf('start[%d].server', $server->master_pid));
2022-01-20 19:04:15 +08:00
\Kiri::getDi()->get(EventDispatch::class)->dispatch(new OnStart($server));
2022-01-09 03:49:02 +08:00
}
/**
* @param \Swoole\Server $server
* @throws ReflectionException
*/
public function onBeforeShutdown(\Swoole\Server $server)
{
2022-01-20 19:04:15 +08:00
\Kiri::getDi()->get(EventDispatch::class)->dispatch(new OnBeforeShutdown($server));
2022-01-09 03:49:02 +08:00
}
/**
* @param \Swoole\Server $server
* @throws ReflectionException
*/
public function onShutdown(\Swoole\Server $server)
{
2022-01-20 19:04:15 +08:00
\Kiri::getDi()->get(EventDispatch::class)->dispatch(new OnShutdown($server));
2022-01-09 03:49:02 +08:00
}
}