From 76acbaea4957a8a7680c791fc7da86ca776cc0cc Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Thu, 5 Jan 2023 02:42:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=EF=BC=8C=E6=AF=8F=E6=AC=A1=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=83=BD=E9=87=8D=E7=BD=AE=20NODE=5FID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Cluster/Work.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/Console/Commands/Cluster/Work.php b/app/Console/Commands/Cluster/Work.php index ad716c3..24afd5a 100644 --- a/app/Console/Commands/Cluster/Work.php +++ b/app/Console/Commands/Cluster/Work.php @@ -38,24 +38,22 @@ public function handle(): int return CommandAlias::FAILURE; } - // if not node_id - if (!config('settings.node.id')) { - // 重写 .env 文件中的 NODE_ID - $this->info('正在重写 .env 文件中的 NODE_ID。'); - $node_id = Str::random(8); + // 重写 .env 文件中的 NODE_ID + $this->info('正在重写 .env 文件中的 NODE_ID。'); - if (config('settings.node.type') === 'master') { - $node_id = 'master'; - } + $node_id = Str::random(8); - $env = file_get_contents(base_path('.env')); - - $env = preg_replace('/^NODE_ID=.*$/m', 'NODE_ID=' . $node_id, $env); - - file_put_contents(base_path('.env'), $env); + if (config('settings.node.type') === 'master') { + $node_id = 'master'; } + $env = file_get_contents(base_path('.env')); + + $env = preg_replace('/^NODE_ID=.*$/m', 'NODE_ID=' . $node_id, $env); + + file_put_contents(base_path('.env'), $env); + // 刷新配置缓存 $this->info('正在刷新配置缓存。');