Require a positive RETENTION_SWEEP_INTERVAL (closes #140)
All checks were successful
check / check (push) Successful in 2m59s
All checks were successful
check / check (push) Successful in 2m59s
envDuration accepted 0s and negative values, and RETENTION_SWEEP_INTERVAL feeds time.NewTicker in both the retention reaper and the archive sweeper. NewTicker panics on a non-positive period, and both tickers are created in goroutines with no recover, so a bad value aborted the process after startup had already logged "Configuration loaded". Add envPositiveDuration, mirroring envPort's wrapping of envPositiveInt, and use it for RETENTION_SWEEP_INTERVAL. It wraps ErrNonPositiveValue and names the variable, the same failure shape PORT and RECEIVER_RATE_LIMIT already have. SESSION_IDLE_TIMEOUT, the only other envDuration caller, stays on envDuration: non-positive there means idle expiry is disabled, which is documented behaviour and guarded at both use sites.
This commit is contained in:
@@ -93,6 +93,7 @@ TTY detection, and security headers are always applied.
|
||||
| `METRICS_USERNAME` | Basic auth username for `/metrics` | `""` |
|
||||
| `METRICS_PASSWORD` | Basic auth password for `/metrics` | `""` |
|
||||
| `SENTRY_DSN` | Sentry error reporting DSN | `""` |
|
||||
| `RETENTION_SWEEP_INTERVAL` | Retention reaper period (Go duration, must be positive) | `1h` |
|
||||
| `SESSION_IDLE_TIMEOUT` | Idle session timeout (Go duration) | `24h` |
|
||||
| `RECEIVER_RATE_LIMIT` | Receiver requests/minute per IP per entrypoint | `120` |
|
||||
| `TRUSTED_PROXIES` | CIDRs whose forwarded headers are trusted | `""` (none) |
|
||||
@@ -173,8 +174,12 @@ its value and refuses to start, rather than silently running with a
|
||||
substituted default. `PORT=eighty`, `DEBUG=ture`, and
|
||||
`RETENTION_SWEEP_INTERVAL=1 hour` all abort startup. `PORT` must
|
||||
additionally be a number in the range 1–65535,
|
||||
`RECEIVER_RATE_LIMIT` must be at least 1, and every entry in
|
||||
`TRUSTED_PROXIES` must be a CIDR block or a bare IP address.
|
||||
`RECEIVER_RATE_LIMIT` must be at least 1,
|
||||
`RETENTION_SWEEP_INTERVAL` must be greater than zero (it is a ticker
|
||||
period, so `0s` or a negative value would crash the reaper after
|
||||
startup), and every entry in `TRUSTED_PROXIES` must be a CIDR block or
|
||||
a bare IP address. `SESSION_IDLE_TIMEOUT` is the exception: a
|
||||
non-positive value there means idle expiry is disabled, not invalid.
|
||||
|
||||
Boolean variables (`DEBUG`, `MAINTENANCE_MODE`) accept exactly the
|
||||
spellings Go's `strconv.ParseBool` accepts — `1`, `t`, `T`, `TRUE`,
|
||||
|
||||
Reference in New Issue
Block a user