检查控制器健康状态#

health 接口定义如下:

health(instance_id: str) -> event_id: str, error_codes: Dict[int, int]

该函数返回一个 event_id 和一个将 worker_id 映射到 error_code 的字典。值为 0 表示工作正常,而非零值则表示出现错误。

示例用法:#

首先,在 9000 端口启动 lmcache 控制器,在 9001 端口启动监视器:

PYTHONHASHSEED=123 lmcache_controller --host localhost --port 9000 --monitor-port 9001

然后发送健康检查请求:

curl -X POST http://localhost:9000/health \
  -H "Content-Type: application/json" \
  -d '{"instance_id": "lmcache_default_instance"}'

控制器会返回类似于以下内容的消息:

{"event_id": "health47ce328d-f27e-48ae-ab0c-c2218aabce95", "error_codes": {"0": 0, "1": 0}}

这里 error_codes 列出了每个工作者的 error_code0 表示工作者健康,而非零值则表示出现错误。