mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-05-06 02:07:49 +08:00
Service list and minio status (#13480)
### What problem does this PR solve? 1. Resolve standard user can access admin service 2. Get RAGFlow service status 3. Fix minio status fetching ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [x] New Feature (non-breaking change which adds functionality) --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@ -31,6 +31,7 @@ import (
|
||||
"ragflow/internal/model"
|
||||
"ragflow/internal/server"
|
||||
"ragflow/internal/utility"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -282,20 +283,37 @@ func (s *Service) GetAllServices() ([]map[string]interface{}, error) {
|
||||
|
||||
var result []map[string]interface{}
|
||||
for _, configDict := range allConfigs {
|
||||
// Get service details to check status
|
||||
serviceDetail, err := s.GetServiceDetails(configDict)
|
||||
if err == nil {
|
||||
if status, ok := serviceDetail["status"]; ok {
|
||||
configDict["status"] = status
|
||||
serviceType := configDict["service_type"]
|
||||
if serviceType != "ragflow_server" {
|
||||
// Get service details to check status
|
||||
serviceDetail, err := s.GetServiceDetails(configDict)
|
||||
if err == nil {
|
||||
if status, ok := serviceDetail["status"]; ok {
|
||||
configDict["status"] = status
|
||||
} else {
|
||||
configDict["status"] = "timeout"
|
||||
}
|
||||
} else {
|
||||
configDict["status"] = "timeout"
|
||||
}
|
||||
} else {
|
||||
configDict["status"] = "timeout"
|
||||
result = append(result, configDict)
|
||||
}
|
||||
result = append(result, configDict)
|
||||
|
||||
}
|
||||
|
||||
id := len(result)
|
||||
serverList := GlobalServerStatusStore.GetAllStatuses()
|
||||
for _, serverStatus := range serverList {
|
||||
serverItem := make(map[string]interface{})
|
||||
serverItem["name"] = serverStatus.ServerName
|
||||
serverItem["service_type"] = serverStatus.ServerType
|
||||
serverItem["id"] = id
|
||||
id++
|
||||
serverItem["host"] = serverStatus.Host
|
||||
serverItem["port"] = serverStatus.Port
|
||||
serverItem["status"] = "alive"
|
||||
result = append(result, serverItem)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@ -540,6 +558,7 @@ func (s *Service) checkMinioAlive(name string) (map[string]interface{}, error) {
|
||||
|
||||
// Get minio config from allConfigs
|
||||
var host string
|
||||
var port int
|
||||
var secure bool
|
||||
var verify bool = true
|
||||
|
||||
@ -550,6 +569,16 @@ func (s *Service) checkMinioAlive(name string) (map[string]interface{}, error) {
|
||||
if h, ok := config["host"].(string); ok {
|
||||
host = h
|
||||
}
|
||||
|
||||
if p, ok := config["port"].(int); ok {
|
||||
port = p
|
||||
} else if p, ok := config["port"].(float64); ok {
|
||||
port = int(p)
|
||||
} else if p, ok := config["port"].(string); ok {
|
||||
if parsedPort, err := strconv.Atoi(p); err == nil {
|
||||
port = parsedPort
|
||||
}
|
||||
}
|
||||
// Get secure from extra config
|
||||
if extra, ok := config["extra"].(map[string]interface{}); ok {
|
||||
if s, ok := extra["secure"].(bool); ok {
|
||||
@ -569,7 +598,10 @@ func (s *Service) checkMinioAlive(name string) (map[string]interface{}, error) {
|
||||
|
||||
// Default host
|
||||
if host == "" {
|
||||
host = "localhost:9000"
|
||||
host = "localhost"
|
||||
}
|
||||
if port == 0 {
|
||||
port = 9000
|
||||
}
|
||||
|
||||
// Determine scheme
|
||||
@ -578,7 +610,7 @@ func (s *Service) checkMinioAlive(name string) (map[string]interface{}, error) {
|
||||
scheme = "https"
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s://%s/minio/health/live", scheme, host)
|
||||
url := fmt.Sprintf("%s://%s:%d/minio/health/live", scheme, host, port)
|
||||
|
||||
// Create HTTP client with timeout
|
||||
client := &http.Client{
|
||||
|
||||
Reference in New Issue
Block a user