soulseek: added auto restart

This commit is contained in:
Tigor Hutasuhut 2024-08-21 21:18:54 +07:00
parent cf90158871
commit 48ce3dfa79
2 changed files with 30 additions and 1 deletions

View file

@ -46,6 +46,9 @@ in
EOF 200 EOF 200
''; '';
# Minecraft only autoupdates at startup
#
# To keep up with the update, restart the server at 4am everyday.
systemd = systemd =
let serviceName = "podman-${name}"; in let serviceName = "podman-${name}"; in
{ {

View file

@ -1,4 +1,4 @@
{ config, lib, ... }: { config, lib, pkgs, ... }:
let let
name = "soulseek"; name = "soulseek";
podman = config.profile.podman; podman = config.profile.podman;
@ -23,6 +23,32 @@ in
chown ${uid}:${gid} ${rootVolume} ${rootVolume}/{config,downloads,incomplete} 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} = { virtualisation.oci-containers.containers.${name} = {
inherit image; inherit image;
hostname = name; hostname = name;