somratpro Claude Sonnet 4.6 commited on
Commit
79d2b7b
·
1 Parent(s): fbcca6e

fix: health endpoint always 200 so Docker HEALTHCHECK passes on startup

Browse files

/health was returning 503 when the Hermes gateway hadn't started yet.
Docker HEALTHCHECK uses curl -f which treats 503 as failure, so the
container stayed in "starting" state until the gateway was fully up
(~120s). Combined with start-period=180s, HF Space was stuck at
RUNNING_APP_STARTING indefinitely.

Fix: always return HTTP 200 from /health (gateway status in JSON body).
Reduce start-period to 30s since health server starts in ~2s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (2) hide show
  1. Dockerfile +1 -1
  2. health-server.js +5 -1
Dockerfile CHANGED
@@ -97,7 +97,7 @@ ENV HERMES_HOME=/opt/data \
97
 
98
  EXPOSE 7861
99
 
100
- HEALTHCHECK --interval=30s --timeout=5s --start-period=180s \
101
  CMD curl -fsS http://localhost:7861/health || exit 1
102
 
103
  CMD ["/opt/huggingmes/start.sh"]
 
97
 
98
  EXPOSE 7861
99
 
100
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=30s \
101
  CMD curl -fsS http://localhost:7861/health || exit 1
102
 
103
  CMD ["/opt/huggingmes/start.sh"]
health-server.js CHANGED
@@ -566,7 +566,11 @@ const server = http.createServer(async (req, res) => {
566
 
567
  if (path === "/health" || path === `${APP_BASE}/health`) {
568
  const data = await statusPayload();
569
- res.writeHead(data.ok ? 200 : 503, { "content-type": "application/json" });
 
 
 
 
570
  res.end(
571
  JSON.stringify({
572
  ok: data.ok,
 
566
 
567
  if (path === "/health" || path === `${APP_BASE}/health`) {
568
  const data = await statusPayload();
569
+ // Always 200 health server up means the app is running.
570
+ // Gateway readiness is in the JSON body (gateway: true/false).
571
+ // Returning 503 here caused Docker HEALTHCHECK to fail during gateway
572
+ // startup, keeping HF Space stuck in RUNNING_APP_STARTING indefinitely.
573
+ res.writeHead(200, { "content-type": "application/json" });
574
  res.end(
575
  JSON.stringify({
576
  ok: data.ok,