curl -X GET "http://localhost:5001/health"
const response = await fetch('http://localhost:5001/health');
const data = await response.json();
console.log(data);
import requests
response = requests.get('http://localhost:5001/health')
data = response.json()
print(data)
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/health")
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
{
"status": "ok"
}
{
"status": "error",
"message": "Cluster status check failed"
}
系统
健康检查
检查 WuKongIM 服务器和集群的健康状态
GET
/
health
curl -X GET "http://localhost:5001/health"
const response = await fetch('http://localhost:5001/health');
const data = await response.json();
console.log(data);
import requests
response = requests.get('http://localhost:5001/health')
data = response.json()
print(data)
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/health")
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
{
"status": "ok"
}
{
"status": "error",
"message": "Cluster status check failed"
}
概述
健康检查端点用于监控 WuKongIM 服务器和集群的运行状态,确保系统正常运行。curl -X GET "http://localhost:5001/health"
const response = await fetch('http://localhost:5001/health');
const data = await response.json();
console.log(data);
import requests
response = requests.get('http://localhost:5001/health')
data = response.json()
print(data)
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/health")
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
{
"status": "ok"
}
{
"status": "error",
"message": "Cluster status check failed"
}
响应字段
健康状态:
ok 表示正常,error 表示异常错误信息(仅在状态为 error 时出现)
状态码
| 状态码 | 说明 |
|---|---|
| 200 | 服务器健康状态正常 |
| 500 | 服务器或集群状态异常 |
最佳实践
- 监控频率:建议每 30-60 秒检查一次健康状态
- 超时设置:设置合理的超时时间,避免误报
- 负载均衡:可用于负载均衡器的健康检查
- 容器编排:适用于 Docker 和 Kubernetes 的健康检查配置
- 告警机制:结合监控系统实现自动告警
⌘I

