deploy: make the container restart policy per-host via RESTART_POLICY (#306) #481
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/306-restart-on-failure"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #306.
Seven long-running services were hardcoded
restart: unless-stopped. This closes the drift that let that keep coming back.One deviation from what the issue asked for
#306 says to change the seven services to
restart: on-failure. I've made itrestart: ${RESTART_POLICY:-unless-stopped}instead, and here is why.The issue's own "does this lose anything?" answer is "Not on this host" — and that is right, but this file ships to every install, not just docker-host.
on-failuremeans the stack does not come back after a host reboot. That is correct where a boot sequencer owns startup ordering, and wrong for a plain single-stack install, where it would silently stop the stack returning after a power cut. "Safe for other people to run" is an explicit v4.x goal, so baking a host-specific policy into the shipped default seemed like the wrong trade.Parameterising gets both:
unless-stopped. No existing install changes behaviour.RESTART_POLICY=on-failurein.env→ the seven services take it, which is what docker-host needs.migratestays"no"either way — one-shot, should not restart.Host-specific config lives in that host's
.env, which is where it belongs. Rhoving/iac-repo#296's playbook check is unaffected: it reads the running containers, so it catches drift whichever way the value arrived.The drift had already happened
#306 states the containers "have been flipped live with
docker update --restart on-failure, so the current boot is protected". That was no longer true when I checked. All seven were back onunless-stoppedon docker-host — undone by acompose up -dat some point since 2026-08-12, which is precisely the failure mode the issue predicted.So prod was not protected against the boot race at the time of writing, not merely at some future deploy.
Why the reasoning is in the file
#306 notes the rationale "is not obvious from this repo", and it isn't — it comes from
iac-repoand a specific host's disk topology. The compose header now carries it, as does.env.example, so the next person to seeon-failureand think "that looks wrong" has the answer in front of them rather than having to find iac-repo#279.Verification
docker compose configparses and resolves correctly both ways:RESTART_POLICYunsetunless-stopped,migrate"no"RESTART_POLICY=on-failureon-failure,migrate"no"Both exit 0. No code changes, so no test or lint impact.
Host state — already applied
Both done on docker-host ahead of this merge, so the deploy of this change is a no-op rather than a fix:
RESTART_POLICY=on-failureappended to/home/ryan/Quest-Board/.env(file kept at mode 600).docker update --restart on-failure;migrateleft on"no". Non-disruptive —docker compose psstill reported "Up 3 days (healthy)" for all seven afterwards, so nothing cycled.dev (docker-test) deliberately gets nothing. It has no
staggered-stacksunit — verified — so the whole rationale is absent there and it should keepunless-stoppedso it returns after a reboot. Its containers are correctly on the default.Once this merges,
compose up -don docker-host reads that.envand keeps the policy instead of reverting it, which is the loop #306 exists to close.🤖 Generated with Claude Code
restart: on-failurein docker-compose.yml —unless-stoppedbypasses docker-host's boot pacing #306