From a66eac3b17ee54faddb577c9d84c4eaae7478452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Fri, 27 Aug 2021 18:10:19 +0100 Subject: [PATCH] minecraft: Add automatic restart scheduling This starts/stops the server at 2 pm and 4 am respectively. This should hopefully fix some of the issues caused by shoddy programming. --- configuration/services/minecraft.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/configuration/services/minecraft.nix b/configuration/services/minecraft.nix index af5c75f..bf8f58f 100644 --- a/configuration/services/minecraft.nix +++ b/configuration/services/minecraft.nix @@ -102,4 +102,31 @@ in { "${whitelist}:/var/lib/minecraft/whitelist.json:ro" ]; }; + + systemd.timers.podman-minecraft-voor-kia-off = { + description = "Turns off the minecraft server every day at 4 am"; + wantedBy = [ "podman-minecraft-voor-kia.service" ]; + timerConfig = { + Unit = "podman-minecraft-voor-kia-starter@stop.service"; + OnCalendar = "04:00:00"; + }; + }; + + systemd.timers.podman-minecraft-voor-kia-on = { + description = "Turns on the minecraft server every day at 2 pm"; + wantedBy = [ "podman-minecraft-voor-kia.service" ]; + timerConfig = { + Unit = "podman-minecraft-voor-kia-starter@start.service"; + OnCalendar = "14:00:00"; + }; + }; + + systemd.services."podman-minecraft-voor-kia-starter@" = { + description = "Unit to stop/start the minecraft server"; + serviceConfig = { + ExecStart = + "${pkgs.systemd}/bin/systemctl %i podman-minecraft-voor-kia.service"; + Type = "oneshot"; + }; + }; }