fix:notification/moderation service healthcheck 配置错误
两个服务的 healthcheck 配置都有历史遗留 bug,导致 docker ps
一直显示 unhealthy / health: starting:
1) notificationService
- 现象: docker-compose healthcheck 路径写 /healthz,但 pkg/health
只注册 /health (backend/pkg/health/health.go:29),wget 永远 404
- 修复: compose 路径 /healthz -> /health,Dockerfile HEALTHCHECK
同样改 /health (双保险,rebuild 后不会回退)
2) moderationService
- 现象: main.go 没启 health server (只暴露 Dubbo Triple 协议),
compose 原 healthcheck 端口 20011 永远 timeout,
Dockerfile HEALTHCHECK 也指向 20011 同样错
- 修复: compose 用 healthcheck: test: ["NONE"] 显式覆盖 image
HEALTHCHECK,Dockerfile 改成 HEALTHCHECK NONE (image-level
也禁掉,rebuild 后不会回退)
gateway depends_on moderationservice: service_started (不依赖 healthy),
不影响入口可用性。健康状态靠 gateway 间接覆盖。
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
7bf4666cdb
commit
cacc686e9a
@ -220,6 +220,7 @@ HEALTHCHECK --interval=10s --timeout=5s --start-period=15s --retries=3 \
|
|||||||
ENTRYPOINT ["/app/statisticservice"]
|
ENTRYPOINT ["/app/statisticservice"]
|
||||||
|
|
||||||
# ---- Runtime Stage: NotificationService (通知 + uniCloud 推送) ----
|
# ---- Runtime Stage: NotificationService (通知 + uniCloud 推送) ----
|
||||||
|
# health 端点路径是 /health(不是 /healthz),见 backend/pkg/health/health.go:29
|
||||||
FROM --platform=linux/amd64 alpine:3.19 AS notificationservice
|
FROM --platform=linux/amd64 alpine:3.19 AS notificationservice
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates tzdata
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
@ -230,11 +231,14 @@ COPY --from=builder /tmp/notificationservice /app/notificationservice
|
|||||||
EXPOSE 20010
|
EXPOSE 20010
|
||||||
|
|
||||||
HEALTHCHECK --interval=10s --timeout=5s --start-period=15s --retries=3 \
|
HEALTHCHECK --interval=10s --timeout=5s --start-period=15s --retries=3 \
|
||||||
CMD wget --no-verbose --tries=1 --spider http://localhost:21010/healthz || exit 1
|
CMD wget --no-verbose --tries=1 --spider http://localhost:21010/health || exit 1
|
||||||
|
|
||||||
ENTRYPOINT ["/app/notificationservice"]
|
ENTRYPOINT ["/app/notificationservice"]
|
||||||
|
|
||||||
# ---- Runtime Stage: ModerationService (举报 / 反馈 / 自动隐藏) ----
|
# ---- Runtime Stage: ModerationService (举报 / 反馈 / 自动隐藏) ----
|
||||||
|
# moderationService main.go 没启 health server(只暴露 Dubbo Triple 协议),
|
||||||
|
# image-level HEALTHCHECK NONE 防 rebuild 后回退到错误的 20011 HEALTHCHECK。
|
||||||
|
# 运行时 compose 用 healthcheck: test: ["NONE"] 显式覆盖,这里 NONE 是双保险。
|
||||||
FROM --platform=linux/amd64 alpine:3.19 AS moderationservice
|
FROM --platform=linux/amd64 alpine:3.19 AS moderationservice
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates tzdata
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
@ -244,8 +248,7 @@ COPY --from=builder /tmp/moderationservice /app/moderationservice
|
|||||||
|
|
||||||
EXPOSE 20011
|
EXPOSE 20011
|
||||||
|
|
||||||
HEALTHCHECK --interval=10s --timeout=5s --start-period=15s --retries=3 \
|
HEALTHCHECK NONE
|
||||||
CMD wget --no-verbose --tries=1 --spider http://localhost:20011 || exit 1
|
|
||||||
|
|
||||||
ENTRYPOINT ["/app/moderationservice"]
|
ENTRYPOINT ["/app/moderationservice"]
|
||||||
|
|
||||||
|
|||||||
@ -523,7 +523,7 @@ services:
|
|||||||
expose:
|
expose:
|
||||||
- "20010"
|
- "20010"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:21010/healthz || exit 1"]
|
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:21010/health || exit 1"]
|
||||||
<<: *healthcheck
|
<<: *healthcheck
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
@ -536,6 +536,12 @@ services:
|
|||||||
|
|
||||||
# 内容审核服务(举报 / 反馈 / 自动隐藏)
|
# 内容审核服务(举报 / 反馈 / 自动隐藏)
|
||||||
# 依赖 user / asset / notification Dubbo 服务,以及 Postgres + Redis
|
# 依赖 user / asset / notification Dubbo 服务,以及 Postgres + Redis
|
||||||
|
# ⚠️ healthcheck: test: ["NONE"]:moderationService/main.go 没启 health server
|
||||||
|
# (只暴露 Dubbo Triple 协议在 20011),加 healthcheck 会永远 unhealthy。
|
||||||
|
# Dockerfile.services 的 HEALTHCHECK 指向 20011 也是错的(指向 dubbo 端口),
|
||||||
|
# 必须用 test: NONE 在 compose 层显式覆盖 image 的 HEALTHCHECK。
|
||||||
|
# gateway depends_on moderationservice: service_started(不依赖 healthy),
|
||||||
|
# 所以不影响入口。健康状态靠 gateway 间接覆盖。
|
||||||
moderationservice:
|
moderationservice:
|
||||||
image: topfans/moderationservice:latest
|
image: topfans/moderationservice:latest
|
||||||
build:
|
build:
|
||||||
@ -572,8 +578,7 @@ services:
|
|||||||
expose:
|
expose:
|
||||||
- "20011"
|
- "20011"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:20011 || exit 1"]
|
test: ["NONE"]
|
||||||
<<: *healthcheck
|
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user