From 983eed316034d499feba8b641e68e3e29b723c9b Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Thu, 5 Jan 2023 02:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E8=BF=98=E5=8E=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=8D=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20NODE=5FIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/Cluster/Sync.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Console/Commands/Cluster/Sync.php b/app/Console/Commands/Cluster/Sync.php index c86d85f..e9bb046 100644 --- a/app/Console/Commands/Cluster/Sync.php +++ b/app/Console/Commands/Cluster/Sync.php @@ -107,8 +107,21 @@ public function handle(): int } else { $this->info('正在写入 .env 文件。'); + // $node_ip + $node_ip = config('settings.node.ip'); + // 覆盖 .env 文件 file_put_contents(base_path('.env'), $env); + + // 还原 $node_ip 到 .env + $this->info('正在还原 .env 文件中的 NODE_IP。'); + $env = file_get_contents(base_path('.env')); + + // REPLACE NODE_IP 这一行 + $env = preg_replace('/^NODE_IP=.*$/m', "NODE_IP=${node_ip}", $env); + + file_put_contents(base_path('.env'), $env); + } }