nixos/nats: Shut down gracefully, and prevent automatic restart on deliberate stop

SIGUSR2 puts nats-server into "lame-duck mode", where the node hands off leader roles and hands clients off to other nodes.
This commit is contained in:
Charles Duffy
2025-10-19 06:55:48 -05:00
parent 63bdb5d90f
commit 889b866c82
+9 -1
View File
@@ -138,7 +138,15 @@ in
Type = "simple";
ExecStart = "${pkgs.nats-server}/bin/nats-server -c ${configFile}";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
ExecStop = "${pkgs.coreutils}/bin/kill -SIGINT $MAINPID";
KillMode = "mixed";
KillSignal = "SIGUSR2";
SuccessExitStatus = [
0
"SIGUSR2"
];
TimeoutStopSec = "150"; # must exceed lame_duck_duration, which defaults to 2min
Restart = "on-failure";
User = cfg.user;