Skip to content

健康检查

两个 HTTP 探针职责不同。systemd/容器/编排的重启策略只能绑 liveness,不能绑 readiness。

/health/live/health/ready

路径成功失败用途
GET /health/live进程存活则返回 200连不上 / 进程已死存活。可以据此重启
GET /health/ready准入成功 200503,body {"code":"<REASON>"}是否接流量。不要当重启依据
GET /health/statusJSON:readinesscomponents、脱敏 supervisor若配置了 admin auth 且未带对的 Bearer,则 401看组件状态,不是探针

/health/live 只要 HTTP 服务还在就返回 OK,不表示 SQLite、S3 或 workerd 已就绪。

/health/ready 是聚合准入。code 是稳定的 ReadinessReason,例如 STARTINGREADYDRAININGDATA_DIR_IN_USEDISK_HARD_LIMITS3_UNAVAILABLES3_DEGRADEDRUNTIME_STARTINGRUNTIME_RESTART_BACKOFFRUNTIME_INVALIDMASTER_KEY_MISMATCHMIGRATION_FAILEDSCHEMA_TOO_NEWCONFIG_INVALIDSCHEDULER_UNAVAILABLESCHEDULER_BACKLOGDISK_SOFT_LIMITSNAPSHOT_STALE。503 表示「现在不要把流量打过来」,包括合法的启动中、降级或排空。对 503 重启会打断 backoff、打乱 workerd generation,并把短暂降级变成崩溃循环。

组件名(/health/statuscomponents):processdata_dircontrol_dbmaster_keys3cacheruntimescheduleroperations。状态机:starting / healthy / degraded / failed / draining

监听地址来自配置的 server.public_bind(默认 127.0.0.1:8787)。可选单独的 server.admin_bind

doctordoctor --full

sh
/opt/open-compute/ocd --config /etc/open-compute/config.toml doctor --json
/opt/open-compute/ocd --config /etc/open-compute/config.toml doctor --full --json

两者都要 --config 绝对路径。JSON 含 schema_version(1)、commanddoctor)、resultok / failed)和 checks[]namestatusok / warning / failed / skippedcodemessage、可选非密钥 value)。任一项 failed 则命令以 doctor 失败码退出。

doctordoctor --full
目的默认只读检查授权 S3 canary 和一次临时 workerd 编译/启动/停止
是否初始化 data-dir
另一实例持有锁时,SQLite/schema 等检查会 skip必须拿到 data-dir 排他锁;服务运行时不要执行 full
时机随时只读探查首次成功 run 且干净停机之后

--full 在锁被占或 data-dir 不存在时会 skip s3_canaryr2_canaryruntime_cycle。普通 doctor 也会把这三项标成 skip,并写明需要 full doctor。

doctor 不是健康探针,也不是自愈。损坏的 SQLite、错误的 master key、digest 不匹配都是停止条件,不要靠反复 doctor 修复。

就绪失败时按 故障手册 的症状走,不要先重启碰运气。