mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
feat: 优化节点信息存储
This commit is contained in:
@@ -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();
|
||||
// 首次注册
|
||||
|
||||
Reference in New Issue
Block a user