fix: eliminate 10s container shutdown delay#1373
Conversation
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
Reduces docker compose down latency by ensuring the api-proxy and squid containers terminate promptly on SIGTERM, avoiding the default 10s Compose stop timeout behavior.
Changes:
- Switch
containers/api-proxyto an exec-formCMDso Node receives SIGTERM directly. - Configure Squid with
shutdown_lifetime 0 secondsto avoid waiting on connection draining during shutdown. - Set
stop_grace_period: 2sfor squid and api-proxy in the generated Compose config, and add tests for both settings.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/squid-config.ts |
Adds shutdown_lifetime 0 seconds to the generated squid.conf to speed termination. |
src/squid-config.test.ts |
Asserts the generated config includes the new shutdown directive. |
src/docker-manager.ts |
Adds stop_grace_period: '2s' to squid and api-proxy service definitions. |
src/docker-manager.test.ts |
Verifies stop_grace_period is set on both services in generated compose output. |
containers/api-proxy/Dockerfile |
Replaces shell-form pipeline CMD with exec-form Node CMD to fix signal handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Use exec form so node is PID 1 and receives SIGTERM directly | ||
| CMD ["node", "server.js"] |
Smoke Test Results✅ GitHub MCP: PR #1370 "[WIP] Fix the failing GitHub Actions workflow for test coverage report", PR #1334 "[Test Coverage] test: improve pid-tracker branch coverage for edge cases" Overall: PASS
|
Chroot Version Comparison Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.
|
|
Smoke Test Results — run #23311291777 ✅ GitHub MCP — Last 2 merged PRs: #1370 "[WIP] Fix the failing GitHub Actions workflow for test coverage report", #1340 "docs: update architecture docs with three-component overview" Overall: PASS PR author:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Three root causes of the 10-second shutdown delay: 1. api-proxy Dockerfile used shell-form CMD (node runs under /bin/sh, which doesn't forward SIGTERM to the child process). Switched to exec form so node is PID 1 and handles signals directly. 2. Squid's default shutdown_lifetime (30s) causes it to wait for active connections to drain. Added shutdown_lifetime 0 since this is an ephemeral proxy with no need for connection draining. 3. Docker Compose default stop timeout is 10s. Added stop_grace_period of 2s to squid and api-proxy services since they now shut down promptly on SIGTERM. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c645bb0 to
4a42a0f
Compare
|
Smoke test results for run 23321225306 —
Overall: PASS
|
|
Smoke Test Results — PASS
|
|
🔮 Oracle smoke trace for PR #1373
Warning
|
Chroot Version Comparison Results
Result: 1/3 runtimes match — Go matches, but Python and Node.js versions differ between host and chroot environments.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results — Claude (run 23342821518)✅ GitHub MCP: PR #1374 "fix: update vulnerable dependencies (flatted, markdownlint-cli2)" / PR #1373 "fix: eliminate 10s container shutdown delay" Overall: PASS
|
Summary
Fixes #1371
Three root causes contributed to a ~10-second delay during
docker compose down:api-proxy shell-form CMD: The Dockerfile used
CMD node server.js 2>&1 | tee ...(shell form), sonoderan under/bin/shas a child process./bin/shdoes not forward SIGTERM to children, causing Docker to wait the full stop timeout before sending SIGKILL. Switched to exec formCMD ["node", "server.js"]so node is PID 1 and receives SIGTERM directly.Squid shutdown_lifetime: Squid's default
shutdown_lifetime(30s) causes it to wait for active connections to drain on SIGTERM. Addedshutdown_lifetime 0 secondssince this is an ephemeral per-session proxy with no need for connection draining.Docker Compose stop timeout: Docker Compose defaults to a 10-second stop timeout before sending SIGKILL. Added
stop_grace_period: 2sto squid and api-proxy services, which is sufficient now that both containers shut down promptly on SIGTERM.Test plan
npm run buildcompiles successfullynpm test— all 1119 tests pass, including new tests forshutdown_lifetimeandstop_grace_periodnpm run lint— no errors (only pre-existing warnings)docker compose downcompletes in ~2s instead of ~10s🤖 Generated with Claude Code