From 48ce3dfa79ce3ed8ab42dca9ad479320fcf8cf2a Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Wed, 21 Aug 2024 21:18:54 +0700 Subject: [PATCH] soulseek: added auto restart --- system/podman/minecraft.nix | 3 +++ system/podman/soulseek.nix | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/system/podman/minecraft.nix b/system/podman/minecraft.nix index 59b1079..6e372c0 100644 --- a/system/podman/minecraft.nix +++ b/system/podman/minecraft.nix @@ -46,6 +46,9 @@ in EOF 200 ''; + # Minecraft only autoupdates at startup + # + # To keep up with the update, restart the server at 4am everyday. systemd = let serviceName = "podman-${name}"; in { diff --git a/system/podman/soulseek.nix b/system/podman/soulseek.nix index 6144c85..cd0f1fa 100644 --- a/system/podman/soulseek.nix +++ b/system/podman/soulseek.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: let name = "soulseek"; podman = config.profile.podman; @@ -23,6 +23,32 @@ in chown ${uid}:${gid} ${rootVolume} ${rootVolume}/{config,downloads,incomplete} ''; + + # Soulseek only autoscans on startup + # + # Once a day at 4am, restart the container to trigger a rescan + systemd = + let + serviceName = "podman-${name}-autorestart"; + in + { + services.${serviceName} = { + description = "Podman container ${name} autorestart"; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.podman}/bin/podman restart ${name}"; + }; + }; + timers.${serviceName} = { + description = "Podman container ${name} autorestart"; + timerConfig = { + OnCalendar = "*-*-* 04:00:00"; + }; + wantedBy = [ "timers.target" ]; + }; + }; + + virtualisation.oci-containers.containers.${name} = { inherit image; hostname = name;