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
'';
# Minecraft only autoupdates at startup
#
# To keep up with the update, restart the server at 4am everyday.
systemd =
let serviceName = "podman-${name}"; in
{

View file

@ -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;