Skip to content

fix(docker): start rabbitmq directly and wait for readiness - #332

Open
chrip wants to merge 2 commits into
mainfrom
fix/326-rabbitmq-startup
Open

fix(docker): start rabbitmq directly and wait for readiness#332
chrip wants to merge 2 commits into
mainfrom
fix/326-rabbitmq-startup

Conversation

@chrip

@chrip chrip commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

PR #249 switched the standalone entrypoint from a direct detached start to service rabbitmq-server start for consistency with postgres and redis. The init script goes through start-stop-daemon --background, which wedges under a very large RLIMIT_NOFILE. Docker daemons that pass one through to containers (26.1.5+dfsg1 defaulting to 1073741816 was reported twice) leave the entrypoint stuck before nginx and supervisord ever start: the container looks hung, /healthcheck resets the connection, and nothing in the log says why. Setting ulimits.nofile in compose is a workaround, but users have no way to know that is what is wrong.

Go back to rabbitmq-server -detached, which is unaffected, and follow it with a bounded rabbitmqctl await_startup poll (AMQP_START_TIMEOUT, default 60s). -detached returns before the node registers with epmd, so a single await_startup call fails outright and has to be polled. A timeout now logs rabbitmqctl's own diagnostics and continues to supervisord, like the schema bootstrap above it, so the failure is visible instead of silent.

Apply the same at image build time, where the identical hang would break builds on affected hosts, and drop the mnesia database the build leaves behind: the node name follows the container hostname, so the baked rabbit@buildkitsandbox directory is never read at runtime.

Fixes #326

Assisted-by: ClaudeCode:claude-opus-5

PR #249 switched the standalone entrypoint from a direct detached start to
`service rabbitmq-server start` for consistency with postgres and redis.
The init script goes through `start-stop-daemon --background`, which wedges
under a very large RLIMIT_NOFILE. Docker daemons that pass one through to
containers (26.1.5+dfsg1 defaulting to 1073741816 was reported twice) leave
the entrypoint stuck before nginx and supervisord ever start: the container
looks hung, /healthcheck resets the connection, and nothing in the log says
why. Setting `ulimits.nofile` in compose is a workaround, but users have no
way to know that is what is wrong.

Go back to `rabbitmq-server -detached`, which is unaffected, and follow it
with a bounded `rabbitmqctl await_startup` poll (AMQP_START_TIMEOUT, default
60s). `-detached` returns before the node registers with epmd, so a single
await_startup call fails outright and has to be polled. A timeout now logs
rabbitmqctl's own diagnostics and continues to supervisord, like the schema
bootstrap above it, so the failure is visible instead of silent.

Apply the same at image build time, where the identical hang would break
builds on affected hosts, and drop the mnesia database the build leaves
behind: the node name follows the container hostname, so the baked
`rabbit@buildkitsandbox` directory is never read at runtime.

Fixes #326

Assisted-by: ClaudeCode:claude-opus-5
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
@chrip
chrip requested a review from a team as a code owner August 18, 2026 08:05
@chrip
chrip requested review from rikled and removed request for a team August 18, 2026 08:05
@rikled

rikled commented Aug 18, 2026

Copy link
Copy Markdown
Member

Not sure, but the failed builds appear to be related to the changes.

The build-time wait added alongside the entrypoint one called
`rabbitmqctl await_startup` a single time, and lost the race on three of
the four CI builders: exit 69 after seven seconds with "epmd reports:
node 'rabbit' not running at all", long before its own 60s timeout could
matter. The fourth passed only because the node happened to register
first, so a green run there proved nothing.

start_rabbitmq() in entrypoint.sh already documents why: `-detached`
returns before the node registers with epmd, and until it does
await_startup fails outright instead of waiting. The Dockerfile needed
the same poll and did not get it.

Bounded with `timeout` so a node that never starts still fails the
build, and the wait is then repeated unsuppressed so rabbitmqctl's
diagnostics reach the build log rather than just an exit code.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Christoph Schaefer <christoph.schaefer@nextcloud.com>
@chrip

chrip commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

The wait during the image build asked RabbitMQ "are you ready?" (rabbitmqctl await_startup) exactly once.
RabbitMQ starts in the background and needs a moment to announce itself before
anything can reach it, so that single question came too early and failed instantly
instead of waiting — which broke three of the four builds. The container startup
script already asks in a loop for this reason; the image build now does the same,
with a time limit so a genuinely broken RabbitMQ still fails the build and prints
why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📄 To do

Development

Successfully merging this pull request may close these issues.

Docker latest stuck on RabbitMQ startup, direct rabbitmq-server works

2 participants