From 4d2a264df129107f5e35a1fd2dcba492b4a38139 Mon Sep 17 00:00:00 2001 From: augushong Date: Sat, 23 Aug 2025 23:24:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/base/common/service/HostServiceBase.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extend/base/common/service/HostServiceBase.php b/extend/base/common/service/HostServiceBase.php index 18c26a7..4dc9ad9 100644 --- a/extend/base/common/service/HostServiceBase.php +++ b/extend/base/common/service/HostServiceBase.php @@ -23,7 +23,8 @@ class HostServiceBase public static function getNodeId(): string { // 定义一个持久化存储ID的文件路径 (runtime目录在部署时通常是可写的) - $idFilePath = PathTools::tempBuildPath('node_id.lock'); + $idFilePath = App::getRootPath(). 'runtime/node_id.lock'; + PathTools::intiDir($idFilePath); // 1. 如果ID文件已存在,直接读取并返回 if (file_exists($idFilePath)) { @@ -55,7 +56,7 @@ class HostServiceBase */ public static function heartbeat() { - $nodeId = self::getNodeId(); + $nodeId = static::getNodeId(); if (empty($nodeId)) { Log::error('无法获取当前节点ID,心跳更新失败'); @@ -65,7 +66,7 @@ class HostServiceBase try { $host = SystemHost::where('node_id', $nodeId)->find(); - $data = self::collectHostInfo(); + $data = static::collectHostInfo(); if (empty($host)) { $host = new SystemHost(); // 首次注册