格式化代码

This commit is contained in:
iVampireSP.com 2023-02-08 21:35:11 +08:00
parent 5b70a22901
commit 49128e06ca
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 10 additions and 10 deletions

View File

@ -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;

View File

@ -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。');