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(); // 首次注册