改进 复制方便,每次启动都重置 NODE_ID
This commit is contained in:
parent
c9c65aaafe
commit
76acbaea49
@ -38,24 +38,22 @@ public function handle(): int
|
|||||||
return CommandAlias::FAILURE;
|
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 = Str::random(8);
|
||||||
$node_id = 'master';
|
|
||||||
}
|
|
||||||
|
|
||||||
$env = file_get_contents(base_path('.env'));
|
if (config('settings.node.type') === 'master') {
|
||||||
|
$node_id = 'master';
|
||||||
$env = preg_replace('/^NODE_ID=.*$/m', 'NODE_ID=' . $node_id, $env);
|
|
||||||
|
|
||||||
file_put_contents(base_path('.env'), $env);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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('正在刷新配置缓存。');
|
$this->info('正在刷新配置缓存。');
|
||||||
|
Loading…
Reference in New Issue
Block a user