mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-05-03 08:47:48 +08:00
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:
@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user