Skip to content

Commit

Permalink
mac VMs: add a healthcheck timer
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Aug 19, 2019
1 parent 0cc1c2a commit 47d26b2
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion macs/host/qemu.nix
Expand Up @@ -30,7 +30,8 @@ in {
requires = [ "create-macos-secrets.service" "dhcpd4.service" "kresd.service" "network-online.target" ];
after = requires;
wantedBy = [ "multi-user.target" ];
wants = [ "netcatsyslog.service" ];
wants = [ "netcatsyslog.service" "healthcheck-macos-vm.timer" ];
before = [ "healthcheck-macos-vm.timer" ];
path = with pkgs; [ zfs qemu cdrkit rsync findutils ];

serviceConfig.PrivateTmp = true;
Expand Down Expand Up @@ -71,5 +72,31 @@ in {
-no-reboot
'';
};

systemd.timers.healthcheck-macos-vm = {
enable = true;
description = "Verify the macOS VM is listening";
partOf = [ "run-macos-vm.service"];

timerConfig = {
OnActiveSec = 900;
OnCalendar = "hourly";
Unit = "healthcheck-macos-vm.service";
Persistent = "yes";
};
};

systemd.services.healthcheck-macos-vm = {
enable = true;

script = ''
if ${pkgs.curl}/bin/curl ${config.macosGuest.network.interiorNetworkPrefix}.2 > /dev/null; then
echo "Appears to be up!"
else
echo "Appears to be down, restarting run-macos-vm"
systemctl restart run-macos-vm.service
fi
'';
};
};
}

0 comments on commit 47d26b2

Please sign in to comment.