git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/home-assistant: Restart systemd unit on restart service

Home-assistant through its `--runner` commandline flag supports sending exit code 100 when the `homeassistant.restart` service is called. With `RestartForceExitStatus` we can listen for that specific exit code and restart the whole systemd unit, providing an actual clean restart with fresh processes. Additional treat exit code 100 as a successful termination.

commitf41349d30d5e1cc72c8041616ecb8c36d56f3682 authorMartin Weinelt <hexa@darmstadt.ccc.de> dateMon 26 Apr 2021, 02:39 (6 years ago) parent1dbb60f
1 file changed+3−1
nixos/modules/services/misc/home-assistant.nix+3−1
nixos/modules/services/misc/home-assistant.nix+3−1
@@ -267,11 +267,13 @@ in {
267267 "CAP_NET_RAW"
268268 ]));
269269 in {
270− ExecStart = "${package}/bin/hass --config '${cfg.configDir}'";
270+ ExecStart = "${package}/bin/hass --runner --config '${cfg.configDir}'";
271271 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
272272 User = "hass";
273273 Group = "hass";
274274 Restart = "on-failure";
275+ RestartForceExitStatus = "100";
276+ SuccessExitStatus = "100";
275277 KillSignal = "SIGINT";
276278
277279 # Hardening