fix(docker): add unix socket config and improve supervisord readiness check#1058
fix(docker): add unix socket config and improve supervisord readiness check#1058
Conversation
… check - Add [unix_http_server], [supervisorctl], and [rpcinterface:supervisor] sections to supervisord.conf so supervisorctl can communicate via Unix socket (required for supervisorctl to work correctly) - Improve supervisord readiness check in bootstrap.sh: - Detect if supervisord process dies early and exit immediately - Check for socket file existence before attempting supervisorctl - Use unix:// socket URL directly for supervisorctl calls - Add detailed debug output on startup failure
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a supervisord liveness fast-fail check and changes readiness to verify the UNIX socket plus non-empty Changes
Sequence DiagramsequenceDiagram
participant Bootstrap as bootstrap.sh
participant Supervisord as supervisord
participant Socket as /tmp/supervisor.sock
participant Supervisorctl as supervisorctl
participant Postgres as PostgreSQL (pg_isready)
participant Log as supervisord.log
Bootstrap->>Supervisord: check_supervisord_alive (PID)
alt supervisord alive
Bootstrap->>Postgres: wait with pg_isready loop
loop each iteration
Bootstrap->>Supervisord: check_supervisord_alive
Bootstrap->>Socket: verify socket exists
alt socket exists
Bootstrap->>Supervisorctl: supervisorctl status (via socket)
Supervisorctl->>Socket: connect
Socket->>Supervisord: RPC status request
Supervisord-->>Supervisorctl: status output
Supervisorctl-->>Bootstrap: return output (non-empty => ready)
else socket missing or empty output
Bootstrap->>Log: collect socket state, PID, supervisorctl output, supervisord.log
Bootstrap-->>Bootstrap: retry / eventually timeout
end
end
else supervisord died
Bootstrap->>Log: log process death and exit fast-fail
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docker/bootstrap.sh`:
- Around line 152-157: The current liveness check for supervisord (using
SUPERVISOR_PID) only runs in the later wait loop and can miss supervisord
crashing during the PostgreSQL readiness wait; add an immediate fail-fast check
right after you start supervisord and also perform the same kill -0
$SUPERVISOR_PID check inside the PostgreSQL wait loop (the code that waits for
PostgreSQL readiness) so the script exits early if supervisord dies, printing
the supervisord log (e.g., /var/log/supervisor/supervisord.log) and returning
non-zero; reference SUPERVISOR_PID and the supervisord start block to locate
where to add the checks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 38ca1151-16e8-4510-b63d-ccb9aa50832f
📒 Files selected for processing (2)
docker/bootstrap.shdocker/supervisord.conf
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docker/bootstrap.sh (1)
162-184: Solid readiness check implementation with comprehensive debug output.The socket existence check (
-S) gating thesupervisorctlcall, combined with verifying non-empty status output, is a robust approach. The socket path and URL format correctly match thesupervisord.confconfiguration.One minor inconsistency: Line 176 uses
$SUPERVISOR_PIDwithout quotes in the debug output, while thecheck_supervisord_alivefunction quotes it. Consider quoting for consistency:💅 Suggested consistency fix
- echo " Supervisord PID: $SUPERVISOR_PID (running: $(kill -0 $SUPERVISOR_PID 2>/dev/null && echo yes || echo no))" + echo " Supervisord PID: $SUPERVISOR_PID (running: $(kill -0 "$SUPERVISOR_PID" 2>/dev/null && echo yes || echo no))"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docker/bootstrap.sh` around lines 162 - 184, The debug echo prints $SUPERVISOR_PID unquoted causing inconsistency with check_supervisord_alive; update the echo that outputs the Supervisord PID to quote the variable (and guard/expand safely if empty) so it matches the quoting style used in check_supervisord_alive and prevents word-splitting or empty-value surprises when evaluating supervisorctl/kill checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docker/bootstrap.sh`:
- Around line 162-184: The debug echo prints $SUPERVISOR_PID unquoted causing
inconsistency with check_supervisord_alive; update the echo that outputs the
Supervisord PID to quote the variable (and guard/expand safely if empty) so it
matches the quoting style used in check_supervisord_alive and prevents
word-splitting or empty-value surprises when evaluating supervisorctl/kill
checks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1d41c912-72f2-48dc-a2c5-9ffc57e1906d
📒 Files selected for processing (1)
docker/bootstrap.sh
Description
Fix Docker container startup failure caused by missing supervisord Unix socket configuration.
Problem:
supervisorctlcould not communicate withsupervisordbecause the Unix socket was never declared in [supervisord.conf]. This caused the bootstrap readiness loop to always time out, even when supervisord was running correctly.Changes:
[supervisord.conf]: Added [unix_http_server], [supervisorctl], and [rpcinterface:supervisor] sections to configure the Unix socket at /var/run/supervisor.sock[bootstrap.sh]: Improved the supervisord readiness check to:Type of Change
Additional Notes
Tested by verifying the supervisord socket handshake sequence in the bootstrap loop. Without the [unix_http_server] section, supervisord never creates the socket file, so supervisorctl status always fails silently and the container exits after the 30-iteration timeout.
Summary by CodeRabbit