Support server health check by http://localhost:<port>/v1/system/healthz (#10150)

### What problem does this PR solve?

Support server health check. Solved issue: #10106

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Billy Bao
2025-09-19 11:11:07 +08:00
committed by GitHub
parent a04c5247ab
commit a24547aa66
5 changed files with 153 additions and 122 deletions

View File

@ -4102,3 +4102,77 @@ Failure:
```
---
### System
---
### Check system health
**GET** `/v1/system/healthz`
Check the health status of RAGFlows dependencies (database, Redis, document engine, object storage).
#### Request
- Method: GET
- URL: `/v1/system/healthz`
- Headers:
- 'Content-Type: application/json'
(no Authorization required)
##### Request example
```bash
curl --request GET
--url http://{address}/v1/system/healthz
--header 'Content-Type: application/json'
```
##### Request parameters
- `address`: (*Path parameter*), string
The host and port of the backend service (e.g., `localhost:7897`).
---
#### Responses
- **200 OK** All services healthy
```http
HTTP/1.1 200 OK
Content-Type: application/json
{
"db": "ok",
"redis": "ok",
"doc_engine": "ok",
"storage": "ok",
"status": "ok"
}
```
- **500 Internal Server Error** At least one service unhealthy
```http
HTTP/1.1 500 INTERNAL SERVER ERROR
Content-Type: application/json
{
"db": "ok",
"redis": "nok",
"doc_engine": "ok",
"storage": "ok",
"status": "nok",
"_meta": {
"redis": {
"elapsed": "5.2",
"error": "Lost connection!"
}
}
}
```
Explanation:
- Each service is reported as "ok" or "nok".
- The top-level `status` reflects overall health.
- If any service is "nok", detailed error info appears in `_meta`.