Health checks
A deploy only counts once the service is healthy. muster decides that by running the service's health.sh hook.
How it works
After deploy.sh succeeds, muster runs .muster/hooks/<service>/health.sh (or a health justfile recipe). Exit 0 means healthy; anything else means unhealthy. The same hook runs for muster status, muster dev and the dashboard. For remote services it runs on the remote host.
The type in muster.json (http, tcp or command) doesn't replace the hook: setup uses it to generate health.sh, and status, explain and doctor use it to probe a failing service and name the cause (wrong port, refused, timeout, 4xx, 5xx).
Configure a check
Pick the check when you run setup, or pass it as a flag:
muster setup --scan --health api=http:/health:8080
muster setup --scan --health redis=tcp:6379
muster setup --scan --health worker=command:./check.sh
muster setup --scan --health api=none"api": {
"health": {
"enabled": true,
"type": "http",
"endpoint": "/health",
"port": 8080,
"timeout": 30
}
}Write your own check
health.sh gets the same environment as every other hook, including credentials. Check what actually matters for the service:
#!/usr/bin/env bash
set -euo pipefail
curl -sf http://localhost:8080/health > /dev/null
pg_isready -h db -U appWhen a check fails
In a terminal, muster asks what to do:
| Option | What it does |
|---|---|
| Continue anyway | Go on to the next service. |
| Rollback <name> | Run the service's rollback hook. |
| Abort | Stop the deploy. |
Without a terminal the service is recorded as unhealthy and the deploy exits 1. muster explain shows the likely cause.
Health keys
| Key | Description |
|---|---|
enabled | false turns the check off. |
type | http, tcp or command. |
endpoint | Path for http checks. |
port | Port for http and tcp checks. |
command | Command for command checks. |
timeout | Seconds. The setup wizard sets 30 (production), 15 (staging) or 5 (development); otherwise default_health_timeout (10). |