Answer image requests with 503 in maintenance mode (closes #71)
check / check (push) Successful in 3m29s
check / check (push) Successful in 3m29s
maintenance_mode was only reported by the health check; every request was still served. One middleware in routes.go, applied to /v1/image/ and /v1/e/ only, now answers them with 503, a Retry-After of MaintenanceRetryAfterSeconds and the JSON error body while it is on. It calls Server.MaintenanceMode(), which had no caller. The health check stays 200 and reports maintenance_mode, since the image's Docker HEALTHCHECK and upaas read it; the login and URL generator pages and /metrics keep working. Documented in README.md and config.example.yml. Model: opus-5-5
This commit is contained in:
@@ -239,7 +239,7 @@ variables set by the file's `env:` section are checked the same way.
|
||||
| `PIXA_METRICS_PASSWORD` | `metrics.password` | Password for `/metrics`; set together with the username |
|
||||
| `PIXA_SENTRY_DSN` | `sentry_dsn` | Sentry DSN for error reporting; empty disables it |
|
||||
| `PIXA_DEBUG` | `debug` | Debug logging and plain-HTTP local development; default `false` |
|
||||
| `PIXA_MAINTENANCE_MODE` | `maintenance_mode` | Maintenance flag reported by the health check; default `false` |
|
||||
| `PIXA_MAINTENANCE_MODE` | `maintenance_mode` | Answer image requests with 503; the health check stays 200; default `false` |
|
||||
|
||||
Key settings in more detail:
|
||||
|
||||
@@ -276,6 +276,12 @@ Key settings in more detail:
|
||||
- `cache_max_bytes` — disk cache size limit in bytes; `0` disables the
|
||||
disk cache entirely; omitted defaults to 75% of the free space on
|
||||
the filesystem containing `<state_dir>/cache/` (minimum 500 MiB)
|
||||
- `maintenance_mode` — while `true`, the image routes (`/v1/image/` and
|
||||
`/v1/e/`) answer every request with 503, a `Retry-After` header and a JSON
|
||||
error body. The health check (`/.well-known/healthcheck.json`) still answers
|
||||
200 and reports `"maintenance_mode": true`: the image's Docker `HEALTHCHECK`
|
||||
and upaas both read it, and a 503 there would make upaas mark the deploy
|
||||
failed. The login and URL generator pages and `/metrics` keep working
|
||||
|
||||
See `config.example.yml` for all options with defaults.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user