public mail vpn: reload caddy on a Caddyfile change instead of restarting it (nix-config#926) #1960
No reviewers
Labels
No labels
backlog
bug
enhancement
in-progress
review
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ymrtech/nix-config!1960
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "kb/NCFG-926-caddy-reload"
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?
Card: nix-config#926 (board https://board.ymrtech.com)
What
services.caddy.enableReload = falseon public, mail and vpn ->true.With
false, the nixpkgs caddy module puts the rendered Caddyfile inrestartTriggers, so any Caddyfile change (vhost, route, cert line, log format)is a full
systemctl restart caddy= whole-site outage. Measured on public:56 restarts in 7 days, 4-15 s each (VictoriaLogs
UNIT:"caddy.service" AND (_msg:"Stopping" OR _msg:"Started")).With
truethe Caddyfile moves toreloadTriggersand the module addsExecReload = caddy reload --config /etc/caddy/caddy_config --adapter caddyfile --force,which is graceful: the old process keeps serving until the new config is applied.
trueis the nixpkgs module default;vpn-mxnever overrode it, so these threehosts were the odd ones out. All three already configure the loopback admin API
the reload path needs (
admin localhost:2019inglobalConfig).Evidence (evaluated from this branch)
For each of public, mail and vpn,
systemd.services.caddynow reads:and each host's
system.build.toplevel.drvPathevaluates.X-Reload-Triggersis handled by the rustswitch-to-configurationshipped inthe pinned nixpkgs (rev 7b66dac): it prints
would reload the following units:.Note on the live check
The switch that MOVES the config from restart to reload triggers also changes the
unit definition, so it can still restart caddy once - that transition is
unavoidable. The DoD's "a deploy that changes the Caddyfile reloads" is therefore
verified with a second, config-content-only deploy on public (PR2), which changes
nothing but the Caddyfile.