mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-06 01:52:48 +08:00
fix(host): 防止主节点重复并修复 setMaster 权限
Clear all is_master flags before electing new master to prevent multiple master records. Fix setMaster annotation from @auth true to proper @NodeAnotation format so permission node is generated correctly. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -79,6 +79,8 @@ class HostServiceBase
|
||||
// 主节点自动选举:若无在线主节点,当前节点自动成为主节点
|
||||
$master = SystemHost::where('is_master', 1)->where('status', 1)->find();
|
||||
if (empty($master)) {
|
||||
// 先清除所有旧的主节点标记(含已离线的),避免出现多个 is_master=1
|
||||
SystemHost::where('is_master', 1)->update(['is_master' => 0]);
|
||||
$host->is_master = 1;
|
||||
$host->save();
|
||||
Log::info("节点 [{$nodeId}] 自动当选为主节点。");
|
||||
|
||||
Reference in New Issue
Block a user