2021-07-18 12:06:56 +08:00
|
|
|
<?php
|
|
|
|
|
|
2021-10-25 18:20:29 +08:00
|
|
|
namespace Server\Handler;
|
2021-07-18 12:06:56 +08:00
|
|
|
|
2021-08-12 14:08:40 +08:00
|
|
|
use Annotation\Inject;
|
|
|
|
|
use Kiri\Events\EventDispatch;
|
2021-07-19 19:04:13 +08:00
|
|
|
use Server\Abstracts\Server;
|
2021-08-11 01:04:57 +08:00
|
|
|
use Kiri\Exception\ConfigException;
|
2021-08-12 14:08:40 +08:00
|
|
|
use Server\Events\OnManagerStart;
|
|
|
|
|
use Server\Events\OnManagerStop;
|
2021-07-19 19:04:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-08-05 16:15:42 +08:00
|
|
|
* Class OnServerManager
|
2021-07-19 19:04:13 +08:00
|
|
|
* @package Server\Manager
|
|
|
|
|
*/
|
2021-08-05 16:15:42 +08:00
|
|
|
class OnServerManager extends Server
|
2021-07-18 12:06:56 +08:00
|
|
|
{
|
|
|
|
|
|
2021-08-12 14:08:40 +08:00
|
|
|
/**
|
|
|
|
|
* @var EventDispatch
|
|
|
|
|
*/
|
|
|
|
|
#[Inject(EventDispatch::class)]
|
|
|
|
|
public EventDispatch $eventDispatch;
|
2021-07-18 12:06:56 +08:00
|
|
|
|
2021-08-12 14:08:40 +08:00
|
|
|
|
|
|
|
|
/**
|
2021-07-26 03:18:09 +08:00
|
|
|
* @param \Swoole\Server $server
|
2021-08-05 16:21:31 +08:00
|
|
|
* @throws ConfigException
|
2021-07-26 03:18:09 +08:00
|
|
|
*/
|
2021-07-19 19:04:13 +08:00
|
|
|
public function onManagerStart(\Swoole\Server $server)
|
2021-07-18 12:06:56 +08:00
|
|
|
{
|
2021-07-26 02:58:45 +08:00
|
|
|
$this->setProcessName(sprintf('manger[%d].0', $server->manager_pid));
|
2021-07-26 02:55:55 +08:00
|
|
|
|
2021-08-12 14:08:40 +08:00
|
|
|
$this->eventDispatch->dispatch(new OnManagerStart($server));
|
2021-07-18 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-07-19 19:04:13 +08:00
|
|
|
/**
|
|
|
|
|
* @param \Swoole\Server $server
|
|
|
|
|
*/
|
|
|
|
|
public function onManagerStop(\Swoole\Server $server)
|
|
|
|
|
{
|
2021-08-12 14:08:40 +08:00
|
|
|
$this->eventDispatch->dispatch(new OnManagerStop($server));
|
2021-07-18 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|