From 49128e06ca5776ead8224d70826ad3de1702a025 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Wed, 8 Feb 2023 21:35:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Cluster/Log.php | 12 ++++++------ app/Console/Commands/Cluster/Work.php | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Console/Commands/Cluster/Log.php b/app/Console/Commands/Cluster/Log.php index f8791ef..158f645 100644 --- a/app/Console/Commands/Cluster/Log.php +++ b/app/Console/Commands/Cluster/Log.php @@ -40,11 +40,11 @@ private function format(string $event, array $message = []) { $status = $this->switch($event, $message['data']); - if (!$status) { + if (! $status) { return; } - $message = "[{$message['node']['type']}] {$message['node']['id']}:$event: " . $status; + $message = "[{$message['node']['type']}] {$message['node']['id']}:$event: ".$status; $this->info($message); } @@ -61,16 +61,16 @@ public function switch($event, $message = []): string|null 'config.synced' => '我已下载配置文件。', 'edge.deployed' => '已成功根据集群节点生成配置文件并应用。', 'edge.launched' => '边缘节点成功启动。', - 'edge.error' => fn($message) => $message['message'] ?? '未知错误', + 'edge.error' => fn ($message) => $message['message'] ?? '未知错误', 'cluster.restart.web' => '正在重启 web 服务。', 'cluster.restart.all' => '正在重启 整个 服务。', 'cluster.restarted.web' => 'Web 重启好了。', 'cluster.restarted.all' => '整个 重启好了。', 'cluster.deployed' => '集群配置文件已经部署。', - 'cluster.deployed.error' => fn($message) => $message['message'] ?? '未知错误', + 'cluster.deployed.error' => fn ($message) => $message['message'] ?? '未知错误', 'cluster.deployed.ok' => '集群配置文件部署成功。', - 'http.incoming' => fn($message) => $this->handleIncomingRequest($message), - 'http.outgoing' => fn($message) => $this->handleOutgoingRequest($message), + 'http.incoming' => fn ($message) => $this->handleIncomingRequest($message), + 'http.outgoing' => fn ($message) => $this->handleOutgoingRequest($message), ]; $resp = $events[$event] ?? null; diff --git a/app/Console/Commands/Cluster/Work.php b/app/Console/Commands/Cluster/Work.php index 2094853..03fcaa7 100644 --- a/app/Console/Commands/Cluster/Work.php +++ b/app/Console/Commands/Cluster/Work.php @@ -32,7 +32,7 @@ class Work extends Command public function handle(): int { // 检测目录下是否有 rr - if (!file_exists(base_path('rr'))) { + if (! file_exists(base_path('rr'))) { $this->warn('未找到 rr 文件,将自动下载。'); // 获取操作系统是 darwin 还是 linux @@ -77,7 +77,7 @@ public function handle(): int $node_ip = config('settings.node.ip'); - if (!$node_ip) { + if (! $node_ip) { $this->error('请先配置节点 IP。'); return CommandAlias::FAILURE; @@ -105,14 +105,14 @@ public function handle(): int $this->error('无法创建子进程。'); return CommandAlias::FAILURE; - } else if ($pid === 0) { + } elseif ($pid === 0) { // 再打开一个,负责 octane $pid = pcntl_fork(); if ($pid === -1) { $this->error('无法创建子进程。'); return CommandAlias::FAILURE; - } else if ($pid === 0) { + } elseif ($pid === 0) { // 子进程 $this->info('正在启动 Web。');