cleaner systemd

This commit is contained in:
Osman Faruk Bayram 2025-11-07 10:18:33 +03:00
parent 4adc8da597
commit 0c67559965

View file

@ -74,37 +74,41 @@ in
config.services.wanikani-stats.port config.services.wanikani-stats.port
]; ];
systemd.services.wanikani-stats = { systemd = {
description = "WaniKani Stats Service"; services = {
after = [ "network.target" ]; wanikani-stats = {
wantedBy = [ "multi-user.target" ]; description = "WaniKani Stats Service";
serviceConfig = { after = [ "network.target" ];
Type = "simple"; wantedBy = [ "multi-user.target" ];
ExecStart = "${lib.getExe wanikani-stats-flask}"; serviceConfig = {
StateDirectory = "/var/lib/wanikani-stats"; Type = "simple";
Restart = "on-failure"; ExecStart = "${lib.getExe wanikani-stats-flask}";
User = "root"; StateDirectory = "/var/lib/wanikani-stats";
Group = "root"; Restart = "on-failure";
}; User = "root";
}; Group = "root";
};
};
# Timer to restart the service every 12 hours # Timer to restart the service every 12 hours
systemd.services.wanikani-stats-restart = { wanikani-stats-restart = {
description = "Restart WaniKani Stats Service"; description = "Restart WaniKani Stats Service";
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
ExecStart = "${pkgs.systemd}/bin/systemctl restart wanikani-stats.service"; ExecStart = "${pkgs.systemd}/bin/systemctl restart wanikani-stats.service";
User = "root"; User = "root";
};
};
}; };
};
systemd.timers.wanikani-stats-restart = { timers.wanikani-stats-restart = {
description = "Timer to restart WaniKani Stats Service every 12 hours"; description = "Timer to restart WaniKani Stats Service every 12 hours";
wantedBy = [ "timers.target" ]; wantedBy = [ "timers.target" ];
timerConfig = { timerConfig = {
OnCalendar = "*-*-* 00,12:00:00"; OnCalendar = "*-*-* 00,12:00:00";
Persistent = true; Persistent = true;
RandomizedDelaySec = "5m"; RandomizedDelaySec = "5m";
};
}; };
}; };
}; };