summary refs log tree commit diff
path: root/nixos/modules/services/networking/unifi.nix
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2021-10-13 19:27:42 +0200
committerKerstin <kerstin@erictapen.name>2021-10-14 13:26:14 +0200
commit300226261fe5bcabb070a68c1a837e6938566370 (patch)
tree302ae601a037814ad5a5dd2d0b19e1606dafd341 /nixos/modules/services/networking/unifi.nix
parentb53c5c4552d80056d648239c922896835da0035a (diff)
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.
Diffstat (limited to 'nixos/modules/services/networking/unifi.nix')
-rw-r--r--nixos/modules/services/networking/unifi.nix6
1 files changed, 6 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/unifi.nix b/nixos/modules/services/networking/unifi.nix
index 708ea28a94400..530614ad93742 100644
--- a/nixos/modules/services/networking/unifi.nix
+++ b/nixos/modules/services/networking/unifi.nix
@@ -172,9 +172,15 @@ in
         ExecStart = "${(removeSuffix "\n" cmd)} start";
         ExecStop = "${(removeSuffix "\n" cmd)} stop";
         Restart = "on-failure";
+        TimeoutSec = "5min";
         User = "unifi";
         UMask = "0077";
         WorkingDirectory = "${stateDir}";
+        # the stop command exits while the main process is still running, and unifi
+        # wants to manage its own child processes. this means we have to set KillSignal
+        # to something the main process ignores, otherwise every stop will have unifi.service
+        # fail with SIGTERM status.
+        KillSignal = "SIGCONT";
 
         # Hardening
         AmbientCapabilities = "";