Skip to content

fix: add tini as init to reap Docker healthcheck zombie children#421

Merged
DeliciousBuding merged 1 commit into
masterfrom
fix/server-hub-tini-zombie-reaper
Jul 13, 2026
Merged

fix: add tini as init to reap Docker healthcheck zombie children#421
DeliciousBuding merged 1 commit into
masterfrom
fix/server-hub-tini-zombie-reaper

Conversation

@DeliciousBuding

@DeliciousBuding DeliciousBuding commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Root cause

server-hub runs as PID 1 in the container (entrypoint exec). Docker healthcheck spawns wget -qO- http://localhost:8080/health every 30-90s inside the container PID namespace. When these children exit, Go runtime's SIGCHLD handler only reaps processes started via os/exec — not externally injected Docker healthcheck children.

Production evidence: ~150 wget zombies accumulated over 3 days on hk2, ~16 on us1. All with parent ./server-hub (PID 1).

Fix

Add tini as init (PID 1) via apk add tini + ENTRYPOINT tini -- entrypoint.sh. tini handles SIGCHLD and reaps all orphaned children — standard Docker best practice for non-C-native binaries.

Changes: 2 lines in Dockerfile only. Zero Go code changes.

  • apk add --no-cache ... tini
  • ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]

Closes #420

Summary by CodeRabbit

  • Bug Fixes
    • Improved container startup and process handling for more reliable application shutdown and signal management.
    • Updated runtime setup to include the required initialization support.

Root cause: server-hub runs as PID 1 in the container (entrypoint exec).
Docker healthcheck spawns 'wget -qO- http://localhost:8080/health' every
30-90s inside the container PID namespace. When these children exit, Go
runtime only reaps processes started via os/exec - not externally injected
Docker healthcheck children. Result: ~150 wget zombies accumulated over 3
days on production (hk2 + us1).

Fix: tini as PID 1 handles SIGCHLD and reaps all orphaned children.
Standard Docker best practice for non-C-native binaries.

Closes #420.
Copilot AI review requested due to automatic review settings July 13, 2026 03:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7bcb97b1-b516-4bda-a86a-676d972e3436

📥 Commits

Reviewing files that changed from the base of the PR and between 65b22e2 and 2e03359.

📒 Files selected for processing (1)
  • hub-server/deployments/Dockerfile

📝 Walkthrough

Walkthrough

The runtime Docker image consolidates package installation, adds tini, updates the init-process comment, and changes container startup to invoke docker-entrypoint.sh through tini.

Changes

Runtime container initialization

Layer / File(s) Summary
Install and wire tini
hub-server/deployments/Dockerfile
The runtime stage installs tini with the existing packages and changes ENTRYPOINT to launch docker-entrypoint.sh through /sbin/tini.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The change only wraps the container with tini; it does not fix the wget spawn path or add Wait()/net/http healthchecks. Update the server-hub code or healthcheck path so child processes are reaped with Wait()/Wait4, or replace shell-out wget checks with net/http.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding tini as the container init process to reap zombie children.
Out of Scope Changes check ✅ Passed The Dockerfile-only changes are aligned with the stated fix and do not introduce unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/server-hub-tini-zombie-reaper

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DeliciousBuding DeliciousBuding merged commit 6ecd523 into master Jul 13, 2026
17 of 20 checks passed
@DeliciousBuding DeliciousBuding deleted the fix/server-hub-tini-zombie-reaper branch July 13, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] hub-server 泄漏 wget 僵尸进程,累计 150+ 不回收

2 participants