Skip to content

Commit

Permalink
feat(etna): auto restart minecraft servers
Browse files Browse the repository at this point in the history
  • Loading branch information
uku3lig committed Apr 20, 2024
1 parent 54d1033 commit 9cf2e2b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion systems/etna/minecraft.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
lib,
pkgs,
config,
mkSecret,
...
}: let
inherit (config.virtualisation.oci-containers) backend;

mkMinecraftServer = name: {
port,
frpPort,
Expand Down Expand Up @@ -36,7 +39,7 @@
}
];

systemd.services."${config.virtualisation.oci-containers.backend}-${name}".serviceConfig.TimeoutSec = "300";
systemd.services."${backend}-${name}".serviceConfig.TimeoutSec = "300";
};

recursiveMerge = attrList:
Expand Down Expand Up @@ -70,6 +73,23 @@ in
};

virtualisation.oci-containers.backend = "docker";

systemd.services.restart-minecraft-servers = {
wantedBy = ["multi-user.target"];
script = ''
${lib.getExe' pkgs.systemd "systemctl"} restart ${backend}-*.service
'';
serviceConfig.Type = "oneshot";
};

systemd.timers.restart-minecraft-servers = {
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "*-*-* 05:00:00";
Persistent = true;
Unit = "restart-minecraft-servers.service";
};
};
}
(mkMinecraftServers {
ragnamod7 = {
Expand Down

0 comments on commit 9cf2e2b

Please sign in to comment.