Skip to content

fix(docker): add unix socket config and improve supervisord readiness check#1058

Open
vincyf1 wants to merge 3 commits intof:mainfrom
vincyf1:fix/docker-supervisord-socket-config
Open

fix(docker): add unix socket config and improve supervisord readiness check#1058
vincyf1 wants to merge 3 commits intof:mainfrom
vincyf1:fix/docker-supervisord-socket-config

Conversation

@vincyf1
Copy link
Contributor

@vincyf1 vincyf1 commented Mar 9, 2026

Description

Fix Docker container startup failure caused by missing supervisord Unix socket configuration.

Problem: supervisorctl could not communicate with supervisord because 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:
    • Detect early process termination and fail fast (instead of waiting 30s)
    • Gate supervisorctl calls on socket file existence
    • Use the Unix socket URL directly (unix:///var/run/supervisor.sock)
    • Print debug info on startup failure to help with troubleshooting

Type of Change

  • Bug fix
  • Documentation update
  • Other (please describe):

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.

image

Summary by CodeRabbit

  • Chores
    • Improved Docker container startup reliability with enhanced service validation and multi-step health checks, including fast-fail detection of the supervisor process.
    • On startup timeout, emits richer diagnostic information to aid troubleshooting (socket, process and log details).
    • Added Unix-socket support for supervisor management interface.
    • Minor UI text alignment tweak in the final startup banner.

… 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
@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbbd54f5-16d3-4e02-9075-a3db854a9c1c

📥 Commits

Reviewing files that changed from the base of the PR and between b6753e9 and f8cd78d.

📒 Files selected for processing (1)
  • docker/bootstrap.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • docker/bootstrap.sh

📝 Walkthrough

Walkthrough

Adds a supervisord liveness fast-fail check and changes readiness to verify the UNIX socket plus non-empty supervisorctl output during PostgreSQL wait; emits detailed diagnostics on timeout. Also enables a UNIX-domain socket and RPC interface in supervisord config.

Changes

Cohort / File(s) Summary
Supervisord lifecycle & startup script
docker/bootstrap.sh
Adds check_supervisord_alive liveness probe invoked during pg_isready loop; replaces simple supervisorctl status check with socket existence + non-empty supervisorctl output verification; adds verbose debug output (socket state, PID, supervisorctl output, supervisord log) on timeout; minor banner alignment tweak.
Supervisor socket & RPC config
docker/supervisord.conf
Adds [unix_http_server] and [rpcinterface:supervisor] sections and configures supervisorctl to use the UNIX-domain socket for RPC access.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

Poem

🐇 I nudged the socket, peeked at PID and log,
I hopped through checks when startup felt fog.
Socket, status, then PostgreSQL's cheer—
Supervisord wakes, and the systems hear! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding Unix socket configuration to supervisord.conf and improving the supervisord readiness check in bootstrap.sh.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 50c4e97 and 1e47cc7.

📒 Files selected for processing (2)
  • docker/bootstrap.sh
  • docker/supervisord.conf

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
docker/bootstrap.sh (1)

162-184: Solid readiness check implementation with comprehensive debug output.

The socket existence check (-S) gating the supervisorctl call, combined with verifying non-empty status output, is a robust approach. The socket path and URL format correctly match the supervisord.conf configuration.

One minor inconsistency: Line 176 uses $SUPERVISOR_PID without quotes in the debug output, while the check_supervisord_alive function 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1e47cc7 and b6753e9.

📒 Files selected for processing (1)
  • docker/bootstrap.sh

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.

1 participant