Commit Graph
3 Commits
Author SHA1 Message Date
lukaszraczylo 60029a047e fix(cmd): retry a rejected reload and tighten the drain lifecycle
Review findings on the standalone config reload:

- A rejected config is now retried on every check, because the cause can
  be outside the file, such as a secret file that is not mounted yet.
  Each distinct error is logged once. A read error and a build error are
  tracked apart, so one does not hide the other.
- A closed generation stops its drain timer, so the timer no longer
  holds the old gateway in memory until it fires.
- closeCurrent marks the generation retired before it closes, so a late
  request does not run on a closed gateway.
- -reload-drain-timeout must be positive. A zero value closed running
  requests at once.
- The listen-error path waits for the reloader before the close, the
  same as the signal path. The reloader does not build after ctx ends.
2026-11-26 16:30:20 +00:00
lukaszraczylo 6766d92bdd feat(cmd): reload the standalone config when the file changes
The standalone binary now reads its config file every -reload-interval
(default 5s) and on SIGHUP. When the content changes, it builds a new
gateway and sends new requests to it. Requests that already run finish
on the old gateway, which closes when the last one leaves or after
-reload-drain-timeout (default 10m).

A config that does not decode or that New() rejects is logged, and the
old gateway keeps serving. SIGHUP rebuilds even when the content is
unchanged, so a rotated file: secret takes effect.

One atomic word holds the request count and the retired flag. With two
separate atomics, a reload between them could close a gateway that a
new request is still serving.
2026-11-26 16:26:10 +00:00
lukaszraczylo a593b6fc70 feat(cmd): add a standalone gateway binary and container image
cmd/gateway runs the middleware as its own HTTP server behind Traefik.
It reads a YAML config, converts it to JSON and decodes it with
DisallowUnknownFields, so a misspelled key stops startup. It warns
when metrics.allowedCIDRs is set, because behind a proxy the source
address is the proxy's.

The Makefile gains build-binary, docker-build and run-local targets.
The Dockerfile builds from the committed vendor tree and stamps
main.version from the VERSION build argument. go.mod lists
go.yaml.in/yaml/v3 as a direct dependency.

Claude-Session: https://claude.ai/code/session_01V5jYJNxpDFdJkyyExpADrv
2026-09-23 09:44:32 +01:00