Skip to content

docker-compose: restart the server containers after a reboot, and start Passenger on API_PORT - #2531

Open
tencur wants to merge 1 commit into
FarmBot:stagingfrom
tencur:fix/docker-compose-restart-and-port
Open

tencur wants to merge 1 commit into
FarmBot:stagingfrom
tencur:fix/docker-compose-restart-and-port

Conversation

@tencur

@tencur tencur commented Nov 17, 2026

Copy link
Copy Markdown

Two small problems with the docker-compose setup used for LAN self-hosting.

1. Most of the stack does not come back after a reboot or power cut. Only db, delayed_job and log_digests have restart: always. redis, web, mqtt, assets and rabbit_jobs have no policy, so Docker's default (no) applies and they stay down after the host reboots, until someone runs docker compose up again. delayed_job and log_digests do come back, but they can't reach mqtt, so the auto-sync broadcasts made in that time fail and are dropped. RabbitMQ authenticates every login (including the bot's) over HTTP against web, and that path uses redis (BrokerConnectionLimiter), so all three need to be up before a bot can connect. For an unattended self-hosted farm this means the bot stays disconnected after every power cut until someone gets to a terminal. The same happens if one of these containers crashes while the stack is running.

2. Any API_PORT other than 3000 leaves the server unreachable. The web service publishes "${API_PORT}:${API_PORT}", but starts Passenger without --port, so inside the container it always listens on 3000 (Passenger Standalone's default; there is no Passengerfile.json). With API_PORT=80 (which example.env's comment suggests is an option), host port 80 maps to container port 80 where nothing listens. Everything else is built from API_PORT (token iss, $API_URL, the RabbitMQ auth_http URLs), so the web UI, /api/tokens and MQTT logins all fail. The Heroku Procfile already passes -p $PORT.

Changes:

  • docker-compose.yml:
    • add restart: unless-stopped to redis, web, mqtt, assets and rabbit_jobs (unless-stopped rather than always, so docker compose stop still keeps them stopped across a reboot). The typescript watcher is a development tool and is left as it is.
    • start Passenger with --port ${API_PORT:-3000}, so the container listens on the port that is published. With the shipped API_PORT=3000 nothing changes.
  • example.env: note under API_PORT that compose does not terminate SSL, so 443 needs a separate TLS proxy.

Testing: I parsed the changed docker-compose.yml with Python's YAML loader and checked the restart policies and the web command. I don't have Docker on the machine I used, so I couldn't run docker compose up or a reboot test. One thing worth checking: I haven't verified how docker compose run web ... (used in the setup/upgrade instructions) treats the new restart policy for one-off containers.

🤖 Generated with Claude Code

…rt Passenger on API_PORT

Two small problems with the docker-compose setup used for LAN self-hosting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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