mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
nixos/unifi: fix stop behavior
This commit is contained in:
parent
83e97f3599
commit
8bf408f553
2 changed files with 15 additions and 7 deletions
|
|
@ -160,17 +160,14 @@ in
|
|||
serviceConfig = {
|
||||
Type = "notify";
|
||||
ExecStart = "${cmd} start";
|
||||
ExecStop = "${cmd} stop";
|
||||
ExecStop = [
|
||||
"${cmd} stop"
|
||||
"${lib.getExe' pkgs.util-linux "waitpid"} -t 30 -e $MAINPID"
|
||||
];
|
||||
Restart = "always";
|
||||
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 = "";
|
||||
|
|
|
|||
|
|
@ -21,8 +21,19 @@
|
|||
|
||||
machine.wait_for_unit("unifi.service")
|
||||
machine.wait_for_open_port(8880)
|
||||
machine.succeed("systemctl show unifi.service | grep -q 'ActiveState=active'")
|
||||
machine.succeed("pgrep mongod")
|
||||
|
||||
status = json.loads(machine.succeed("curl --silent --show-error --fail-with-body http://localhost:8880/status"))
|
||||
assert status["meta"]["rc"] == "ok"
|
||||
|
||||
machine.succeed("systemctl stop unifi.service")
|
||||
machine.succeed("systemctl show unifi.service | grep -q 'ActiveState=inactive'")
|
||||
machine.fail("pgrep mongod")
|
||||
|
||||
machine.succeed("systemctl start unifi.service")
|
||||
machine.wait_for_unit("unifi.service")
|
||||
machine.succeed("systemctl show unifi.service | grep -q 'ActiveState=active'")
|
||||
machine.succeed("pgrep mongod")
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue