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

@ -96,6 +96,7 @@ sql_command: login_user
| show_fingerprint
| set_license
| show_license
| check_license
| benchmark
// meta command definition
@ -183,6 +184,7 @@ SESSIONS: "SESSIONS"i
SERVER: "SERVER"i
FINGERPRINT: "FINGERPRINT"i
LICENSE: "LICENSE"i
CHECK: "CHECK"i
login_user: LOGIN USER quoted_string ";"
list_services: LIST SERVICES ";"
@ -231,6 +233,7 @@ list_environments: LIST ENVS ";"
show_fingerprint: SHOW FINGERPRINT ";"
set_license: SET LICENSE quoted_string ";"
show_license: SHOW LICENSE ";"
check_license: CHECK LICENSE ";"
list_server_configs: LIST SERVER CONFIGS ";"
@ -496,6 +499,9 @@ class RAGFlowCLITransformer(Transformer):
def show_license(self, items):
return {"type": "show_license"}
def check_license(self, items):
return {"type": "check_license"}
def list_server_configs(self, items):
return {"type": "list_server_configs"}

View File

@ -614,6 +614,17 @@ class RAGFlowClient:
else:
print(f"Fail to show license, code: {res_json['code']}, message: {res_json['message']}")
def check_license(self, command):
if self.server_type != "admin":
print("This command is only allowed in ADMIN mode")
response = self.http_client.request("GET", "/admin/license?check=true", use_api_base=True, auth_kind="admin")
res_json = response.json()
if response.status_code == 200:
print(res_json["data"])
else:
print(f"Fail to show license, code: {res_json['code']}, message: {res_json['message']}")
def list_server_configs(self, command):
"""List server configs by calling /system/configs API and flattening the JSON response."""
response = self.http_client.request("GET", "/system/configs", use_api_base=False, auth_kind="web")
@ -1551,6 +1562,8 @@ def run_command(client: RAGFlowClient, command_dict: dict):
client.set_license(command_dict)
case "show_license":
client.show_license(command_dict)
case "check_license":
client.check_license(command_dict)
case "list_server_configs":
client.list_server_configs(command_dict)
case "create_model_provider":