#!/usr/bin/env bash # Start a real RabbitMQ broker with no Docker and no root. # # RabbitMQ is an Erlang application, so an Erlang runtime and epmd on the path are the whole # dependency. Point ERL_ROOT at an Erlang installation and RABBITMQ_HOME at an unpacked # rabbitmq-server-generic-unix tarball. Ubuntu 22.04 ships Erlang 24, whose newest compatible # broker is 3.10.25; 3.11 and later need Erlang 25. # # The one non-obvious step is starting epmd yourself: rabbitmq-server's own attempt to start it # fails in a container without a resolvable hostname, and the failure surfaces as a forty-line # Erlang crash dump ending in {'EXIT',nodistribution}. set -eu : "${ERL_ROOT:?set ERL_ROOT to an Erlang installation directory}" : "${RABBITMQ_HOME:?set RABBITMQ_HOME to an unpacked rabbitmq-server-generic-unix directory}" export PATH="$ERL_ROOT/bin:$ERL_ROOT/erts-"*/bin":$PATH" export RABBITMQ_MNESIA_BASE="${RABBITMQ_MNESIA_BASE:-/tmp/rmq/data}" export RABBITMQ_LOG_BASE="${RABBITMQ_LOG_BASE:-/tmp/rmq/log}" export RABBITMQ_NODENAME="${RABBITMQ_NODENAME:-rabbit@localhost}" export HOME="${HOME:-/tmp/rmq}" mkdir -p "$RABBITMQ_MNESIA_BASE" "$RABBITMQ_LOG_BASE" epmd -daemon 2>/dev/null || true sleep 1 setsid nohup "$RABBITMQ_HOME/sbin/rabbitmq-server" > /tmp/rmq/boot.log 2>&1 < /dev/null & for _ in $(seq 1 60); do if (echo > /dev/tcp/127.0.0.1/5672) 2>/dev/null; then echo "broker ready on 5672"; exit 0; fi sleep 1 done echo "broker did not start; see /tmp/rmq/boot.log" >&2 exit 1