1
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package com.ruoyi.web.controller.monitor;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.framework.web.domain.Server;
|
||||
import com.ruoyi.jarvis.service.ILogisticsService;
|
||||
import com.ruoyi.jarvis.service.IWxSendService;
|
||||
@@ -27,6 +31,10 @@ public class ServerController
|
||||
|
||||
@Resource
|
||||
private IWxSendService wxSendService;
|
||||
|
||||
/** Ollama 服务地址,用于健康检查 */
|
||||
@Value("${jarvis.ollama.base-url:http://192.168.8.34:11434}")
|
||||
private String ollamaBaseUrl;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||
@GetMapping()
|
||||
@@ -82,6 +90,38 @@ public class ServerController
|
||||
healthMap.put("wxSend", wxSendMap);
|
||||
}
|
||||
|
||||
// Ollama 服务健康检测(调试用)
|
||||
try {
|
||||
String url = ollamaBaseUrl.replaceAll("/$", "") + "/api/tags";
|
||||
String result = HttpUtils.sendGet(url);
|
||||
if (result != null && !result.trim().isEmpty()) {
|
||||
JSONObject json = JSON.parseObject(result);
|
||||
if (json != null && json.containsKey("models") && !json.containsKey("error")) {
|
||||
Map<String, Object> ollamaMap = new HashMap<>();
|
||||
ollamaMap.put("healthy", true);
|
||||
ollamaMap.put("status", "正常");
|
||||
ollamaMap.put("message", "Ollama 服务可用");
|
||||
ollamaMap.put("serviceUrl", ollamaBaseUrl);
|
||||
healthMap.put("ollama", ollamaMap);
|
||||
} else {
|
||||
putOllamaUnhealthy(healthMap, url, json != null && json.getString("error") != null ? json.getString("error") : "返回格式异常");
|
||||
}
|
||||
} else {
|
||||
putOllamaUnhealthy(healthMap, url, "返回为空");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
putOllamaUnhealthy(healthMap, ollamaBaseUrl, "健康检测异常: " + e.getMessage());
|
||||
}
|
||||
|
||||
return AjaxResult.success(healthMap);
|
||||
}
|
||||
|
||||
private void putOllamaUnhealthy(Map<String, Object> healthMap, String url, String message) {
|
||||
Map<String, Object> ollamaMap = new HashMap<>();
|
||||
ollamaMap.put("healthy", false);
|
||||
ollamaMap.put("status", "异常");
|
||||
ollamaMap.put("message", message);
|
||||
ollamaMap.put("serviceUrl", url);
|
||||
healthMap.put("ollama", ollamaMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,6 +205,10 @@ jarvis:
|
||||
# 获取评论接口服务地址(后端转发,避免前端跨域)
|
||||
fetch-comments:
|
||||
base-url: http://192.168.8.60:5008
|
||||
# Ollama 大模型服务(监控健康度调试用)
|
||||
ollama:
|
||||
base-url: http://192.168.8.34:11434
|
||||
model: qwen3.5:9b
|
||||
# 腾讯文档开放平台配置
|
||||
# 文档地址:https://docs.qq.com/open/document/app/openapi/v3/sheet/model/spreadsheet.html
|
||||
tencent:
|
||||
|
||||
@@ -205,6 +205,10 @@ jarvis:
|
||||
# 获取评论接口服务地址(后端转发)
|
||||
fetch-comments:
|
||||
base-url: http://192.168.8.60:5008
|
||||
# Ollama 大模型服务(监控健康度调试用)
|
||||
ollama:
|
||||
base-url: http://192.168.8.34:11434
|
||||
model: qwen3.5:9b
|
||||
# 腾讯文档开放平台配置
|
||||
# 文档地址:https://docs.qq.com/open/document/app/openapi/v3/sheet/model/spreadsheet.html
|
||||
tencent:
|
||||
|
||||
Reference in New Issue
Block a user