fix(docker): run node under tini instead of npm to silence shutdown noise#4222
Open
Danswar wants to merge 1 commit into
Open
fix(docker): run node under tini instead of npm to silence shutdown noise#4222Danswar wants to merge 1 commit into
Danswar wants to merge 1 commit into
Conversation
…oise Every container stop (each release deploy + every restart) logs npm's 5-line 'command failed / signal SIGTERM' ERROR block - npm watching its child die is pure noise, ~80 blocks/week across prd+dev. tini as PID 1 forwards SIGTERM to node, which exits immediately exactly as it did under npm (the app has no shutdown hooks; stop behavior is byte-identical). Bare node as PID 1 was NOT an option: with no SIGTERM handler and PID-1 signal semantics it would ignore the signal and be SIGKILLed after the grace period, slowing every deploy. start:prod wraps nothing but the node invocation (no pre/post hooks, no npm env consumed anywhere in src/) - verified before inlining it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Every container stop — each release deploy plus every restart — logs npm's 5-line
npm error ... signal SIGTERM / command failedblock at ERROR level. Verified 1:1 over the last 7 days: all five develop→main releases produced the block ~6 minutes after merge, and the chronic restarts produce it too (~80 blocks/week across prd+dev). It's pure noise: npm complaining that its child died from the signal it was just sent.What
RUN apk add --no-cache tini+ENTRYPOINT ["/sbin/tini", "--"]in the runtime stage.CMD ["node", "--max-old-space-size=6144", "dist/src/main"]— inlines exactly whatstart:prodruns.Why tini instead of bare node
The app registers no SIGTERM/SIGINT handler (no
enableShutdownHooks(); only anuncaughtExceptionhandler inmain.ts). Bare node as PID 1 would therefore ignore SIGTERM (PID-1 signal semantics: default dispositions don't apply) and get SIGKILLed after the stop-grace period — slowing every deploy and ending in an uncatchable kill. tini as PID 1 forwards SIGTERM to node running as a normal child, which exits immediately — byte-identical stop behavior to today, minus the npm noise.Introducing actual graceful shutdown (
enableShutdownHooks()+ auditing all long-lived handles so the event loop can drain) is deliberately out of scope — it's a behavior change that deserves its own tested PR.Verified before inlining
start:prodstart:prodwraps nothing but the node invocation (no pre/post lifecycle hooks — onlyprebuildexists).src/reads npm-injected env (npm_package_*,npm_config_*,npm_lifecycle_*).command:/entrypoint:for the dfx-api service, so the Dockerfile CMD is authoritative in both deployments.Post-deploy check
First stop after this image rolls out (next deploy or restart): zero
npm errorlines in Loki for the stop event; container stop latency unchanged.