This commit is contained in:
xl
2024-09-04 10:19:03 +08:00
parent e1e44da5b2
commit e4321de504
+6
View File
@@ -4,6 +4,7 @@ namespace Kiri\Server\Abstracts;
use Exception;
use Kiri\Abstracts\Component;
use Kiri\Error\StdoutLogger;
use Kiri\Exception\NotFindClassException;
use Kiri\Server\Config as SConfig;
use Kiri\Server\Constant;
@@ -81,11 +82,14 @@ class AsyncServer extends Component implements ServerInterface
throw new NotFindClassException('Unknown server type ' . $config->type);
}
$this->container->get(StdoutLogger::class)->println('Listen address ' . $config->host . '::' . $config->port);
$this->server = new $match($config->host, $config->port, $config->mode, $config->socket);
$this->server->set($this->systemConfig($config, $daemon));
if (!isset($config->events[Constant::SHUTDOWN])) {
$config->events[Constant::SHUTDOWN] = [OnServer::class, 'onShutdown'];
}
$this->event($this->server, array_merge(\config('server.events', []), $config->events));
$this->container->bind(ServerInterface::class, $this->server);
return $service;
@@ -124,6 +128,8 @@ class AsyncServer extends Component implements ServerInterface
}
$port->set($this->resetSettings($config->type, $config->settings));
$this->event($port, $config->getEvents());
$this->container->get(StdoutLogger::class)->println('Listen address ' . $config->host . '::' . $config->port);
}