Go: Add admin server status checking (#13571)

### What problem does this PR solve?

RAGFlow server isn't available when admin server isn't connected.

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-03-12 20:02:50 +08:00
committed by GitHub
parent 1df804a14a
commit d688b72dff
10 changed files with 181 additions and 26 deletions

View File

@ -17,8 +17,11 @@
package handler
import (
"fmt"
"net/http"
"ragflow/internal/common"
"ragflow/internal/logger"
"ragflow/internal/server/local"
"ragflow/internal/service"
"github.com/gin-gonic/gin"
@ -69,13 +72,21 @@ func (h *AuthHandler) AuthMiddleware() gin.HandlerFunc {
return
}
if !local.IsAdminAvailable() {
license := local.GetAdminStatus()
errMsg := fmt.Sprintf("server license %s, check admin server status", license.Reason)
logger.Warn(errMsg)
c.JSON(http.StatusServiceUnavailable, gin.H{
"code": common.CodeUnauthorized,
"message": errMsg,
"data": "No",
})
return
}
c.Set("user", user)
c.Set("user_id", user.ID)
c.Set("email", user.Email)
c.Next()
}
}
func (h *AuthHandler) LoginByEmail1(c *gin.Context) {
println("hello")
}