This commit is contained in:
2025-12-18 15:39:40 +08:00
parent 37b59c8536
commit 968cdbd11a
7 changed files with 14 additions and 14 deletions
+2 -2
View File
@@ -92,7 +92,7 @@ class AsyncServer extends Component implements ServerInterface
$config->events[Constant::SHUTDOWN] = [OnServer::class, 'onShutdown']; $config->events[Constant::SHUTDOWN] = [OnServer::class, 'onShutdown'];
} }
$this->event($this->server, array_merge(\config('server.events', []), $config->events)); $this->event($this->server, array_merge(\config('servers.server.events', []), $config->events));
$this->container->bind(ServerInterface::class, $this->server); $this->container->bind(ServerInterface::class, $this->server);
return $service; return $service;
} }
@@ -106,7 +106,7 @@ class AsyncServer extends Component implements ServerInterface
*/ */
protected function systemConfig(SConfig $config, int $daemon): array protected function systemConfig(SConfig $config, int $daemon): array
{ {
$settings = array_merge(\config('server.settings', []), $config->settings); $settings = array_merge(\config('servers.server.settings', []), $config->settings);
$settings[Constant::OPTION_DAEMONIZE] = (bool)$daemon; $settings[Constant::OPTION_DAEMONIZE] = (bool)$daemon;
$settings[Constant::OPTION_ENABLE_REUSE_PORT] = true; $settings[Constant::OPTION_ENABLE_REUSE_PORT] = true;
$settings[Constant::OPTION_PID_FILE] = storage('.swoole.pid'); $settings[Constant::OPTION_PID_FILE] = storage('.swoole.pid');
+2 -2
View File
@@ -113,7 +113,7 @@ class HotReload extends AbstractProcess
} }
$this->reloading = true; $this->reloading = true;
di(StdoutLogger::class)->println('reloading server[' . \config('id', 'system-service') . '], please waite.'); di(StdoutLogger::class)->println('reloading server[' . \config('site.id', 'system-service') . '], please waite.');
$this->clear(); $this->clear();
di(ServerInterface::class)->reload(); di(ServerInterface::class)->reload();
@@ -128,7 +128,7 @@ class HotReload extends AbstractProcess
*/ */
protected function addListen(): void protected function addListen(): void
{ {
foreach (config('reload.listen') as $value) { foreach (config('servers.reload.listen') as $value) {
$this->readDirectory($value); $this->readDirectory($value);
} }
} }
+1 -1
View File
@@ -21,7 +21,7 @@ trait TraitServer
*/ */
public function onSignal(): void public function onSignal(): void
{ {
$signal = \config('signal', []); $signal = \config('servers.signal', []);
$this->onPcntlSignal(SIGINT, [$this, 'onSigint']); $this->onPcntlSignal(SIGINT, [$this, 'onSigint']);
foreach ($signal as $sig => $value) { foreach ($signal as $sig => $value) {
if (is_array($value) && is_string($value[0])) { if (is_array($value) && is_string($value[0])) {
+1 -1
View File
@@ -40,7 +40,7 @@ trait TraitProcess
private function genProcess(AbstractProcess $name): Process private function genProcess(AbstractProcess $name): Process
{ {
return new Process(function (Process $process) use ($name) { return new Process(function (Process $process) use ($name) {
$process->name('[' . \config('id', 'system-service') . '].' . $name->getName() . '[' . $process->pid . ']'); $process->name('[' . \config('site.id', 'system-service') . '].' . $name->getName() . '[' . $process->pid . ']');
$name->onShutdown($process)->process($process); $name->onShutdown($process)->process($process);
}, },
$name->getRedirectStdinAndStdout(), $name->getRedirectStdinAndStdout(),
+4 -4
View File
@@ -114,7 +114,7 @@ class ServerCommand extends Command
*/ */
protected function stop(): int protected function stop(): int
{ {
$configs = config('server', []); $configs = config('servers.server', []);
$instances = $this->asyncServer->sortService($configs['ports'] ?? []); $instances = $this->asyncServer->sortService($configs['ports'] ?? []);
foreach ($instances as $config) { foreach ($instances as $config) {
$this->state->exit($config->port); $this->state->exit($config->port);
@@ -131,13 +131,13 @@ class ServerCommand extends Command
*/ */
protected function start(InputInterface $input): int protected function start(InputInterface $input): int
{ {
$this->asyncServer->addProcess(config('processes', [])); $this->asyncServer->addProcess(config('process', []));
if (\config('reload.hot', false) === true) { if (\config('servers.reload.hot', false) === true) {
$this->asyncServer->addProcess([HotReload::class]); $this->asyncServer->addProcess([HotReload::class]);
} else { } else {
di(Router::class)->scan_build_route(); di(Router::class)->scan_build_route();
} }
$this->asyncServer->initCoreServers(config('server', []), (int)$input->getOption('daemon')); $this->asyncServer->initCoreServers(config('servers.server', []), (int)$input->getOption('daemon'));
$this->asyncServer->start(); $this->asyncServer->start();
return 1; return 1;
} }
+1 -1
View File
@@ -21,7 +21,7 @@ class State extends Component
*/ */
public function init(): void public function init(): void
{ {
$this->servers = config('server.ports'); $this->servers = config('servers.server.ports');
} }
+1 -1
View File
@@ -24,7 +24,7 @@ class Task
*/ */
public function __construct() public function __construct()
{ {
$exception = \config('exception.task'); $exception = \config('servers.task.exception');
if (!in_array(ExceptionHandlerInterface::class, class_implements($exception))) { if (!in_array(ExceptionHandlerInterface::class, class_implements($exception))) {
$exception = ExceptionHandlerDispatcher::class; $exception = ExceptionHandlerDispatcher::class;
} }