git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/unifi: fix unifi ExecStop= being incompatible with systemd

unifi does not shut down properly when stopped via systemd (it always exits with SIGTERM exit status) because systemd wants stop commands to not exit before the main command is gone and unifi does not comply. the easiest way around this is to have systemd send an ignored signal after the stop command has exited. unifi may still throw exceptions during shutdown, but it *does* exit cleanly as far as systemd is concerned now.

commit300226261fe5bcabb070a68c1a837e6938566370 authorpennae <github@quasiparticle.net> dateWed 13 Oct 2021, 19:27 (5 years ago) parentb53c5c4
1 file changed+6
nixos/modules/services/networking/unifi.nix+6
nixos/modules/services/networking/unifi.nix+6
@@ -172,9 +172,15 @@ in
172172 ExecStart = "${(removeSuffix "\n" cmd)} start";
173173 ExecStop = "${(removeSuffix "\n" cmd)} stop";
174174 Restart = "on-failure";
175+ TimeoutSec = "5min";
175176 User = "unifi";
176177 UMask = "0077";
177178 WorkingDirectory = "${stateDir}";
179+ # the stop command exits while the main process is still running, and unifi
180+ # wants to manage its own child processes. this means we have to set KillSignal
181+ # to something the main process ignores, otherwise every stop will have unifi.service
182+ # fail with SIGTERM status.
183+ KillSignal = "SIGCONT";
178184
179185 # Hardening
180186 AmbientCapabilities = "";