diff --git a/Abstracts/AsyncServer.php b/Abstracts/AsyncServer.php index d24e11b..70809fb 100644 --- a/Abstracts/AsyncServer.php +++ b/Abstracts/AsyncServer.php @@ -104,8 +104,6 @@ class AsyncServer implements ServerInterface { $this->server = new $match($config->host, $config->port, $config->mode, $config->socket); $this->server->set($this->systemConfig($config, $daemon)); - - Logger::_alert('Listen ' . $config->type . ' address ' . $config->host . '::' . $config->port); if (!isset($config->events[Constant::SHUTDOWN])) { $config->events[Constant::SHUTDOWN] = [OnServer::class, 'onShutdown']; } @@ -161,8 +159,6 @@ class AsyncServer implements ServerInterface throw new Exception('Listen port fail.' . swoole_last_error()); } - Logger::_alert('Listen ' . $config->type . ' address ' . $config->host . '::' . $config->port); - $port->set($this->resetSettings($config->type, $config->settings)); $this->onEventListen($port, $config->getEvents()); diff --git a/Handler/OnServer.php b/Handler/OnServer.php index 1379e45..966143c 100644 --- a/Handler/OnServer.php +++ b/Handler/OnServer.php @@ -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)); + } }