This commit is contained in:
2023-04-16 02:32:36 +08:00
parent 4e390e89d6
commit 2273b3d1bd
+3 -1
View File
@@ -6,6 +6,7 @@ use Exception;
use Kiri\Server\CoroutineServer; use Kiri\Server\CoroutineServer;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
use ReflectionException;
use Swoole\Coroutine; use Swoole\Coroutine;
use Swoole\Http\Server as HServer; use Swoole\Http\Server as HServer;
use Swoole\Server; use Swoole\Server;
@@ -116,13 +117,14 @@ trait TraitServer
/** /**
* @param array $ports * @param array $ports
* @return array<Config> * @return array<Config>
* @throws ReflectionException
*/ */
public function genConfigService(array $ports): array public function genConfigService(array $ports): array
{ {
$array = []; $array = [];
$ports = $ports['ports'] ?? []; $ports = $ports['ports'] ?? [];
foreach ($ports as $port) { foreach ($ports as $port) {
$config = \Kiri::getDi()->create(Config::class, [], $port); $config = \Kiri::getDi()->make(Config::class, [], $port);
if ($port['type'] == Constant::SERVER_TYPE_WEBSOCKET) { if ($port['type'] == Constant::SERVER_TYPE_WEBSOCKET) {
array_unshift($array, $config); array_unshift($array, $config);
} else if ($port['type'] == Constant::SERVER_TYPE_HTTP) { } else if ($port['type'] == Constant::SERVER_TYPE_HTTP) {