This commit is contained in:
2023-08-11 02:35:46 +08:00
parent 3196a7cffb
commit bb4df7307a
2 changed files with 34 additions and 35 deletions
+34 -31
View File
@@ -2,6 +2,7 @@
namespace Kiri\Server\Handler;
use Kiri\Abstracts\Logger;
use Kiri\Di\Inject\Container;
use Kiri\Events\EventDispatch;
use Kiri\Exception\ConfigException;
@@ -25,40 +26,42 @@ class OnServer extends Server
{
/**
* @param SServer $server
* @throws ReflectionException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function onStart(SServer $server): void
{
\Kiri::setProcessName(sprintf('start[%d].server', $server->master_pid));
event(new OnStart($server));
}
/**
* @param SServer $server
* @throws ReflectionException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function onStart(SServer $server): void
{
\Kiri::setProcessName(sprintf('start[%d].server', $server->master_pid));
foreach (config('server.ports') as $value) {
Logger::_alert('Listen ' . $value['type'] . ' address ' . $value['host'] . '::' . $value['port']);
}
event(new OnStart($server));
}
/**
* @param SServer $server
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function onBeforeShutdown(SServer $server): void
{
event(new OnBeforeShutdown($server));
}
/**
* @param SServer $server
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function onBeforeShutdown(SServer $server): void
{
event(new OnBeforeShutdown($server));
}
/**
* @param SServer $server
* @throws
*/
public function onShutdown(SServer $server): void
{
@unlink(storage('.swoole.pid'));
event(new OnShutdown($server));
}
/**
* @param SServer $server
* @throws
*/
public function onShutdown(SServer $server): void
{
@unlink(storage('.swoole.pid'));
event(new OnShutdown($server));
}
}