From cc8d41cd688468afddf50a2505cfcdeb22c2126a Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Sun, 5 Nov 2023 17:15:01 +0100 Subject: [PATCH] periodically update docker container (Jinja-Compose) --- hosts/yodaNas/host-specific.nix | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/hosts/yodaNas/host-specific.nix b/hosts/yodaNas/host-specific.nix index 43fb932..bdfe89c 100644 --- a/hosts/yodaNas/host-specific.nix +++ b/hosts/yodaNas/host-specific.nix @@ -121,12 +121,29 @@ in ]; }; - # Start Jinja-Compose project during boot. - # To few the log, run + # Update and start Jinja-Compose project + # during boot and after every 30 minutes. + # To view the log, run # journalctl -b -u Jinja-Compose -f # + systemd.timers."Jinja-Compose" = { + wantedBy = [ "timers.target" ]; + partOf = [ "Jinja-Compose.service" ]; + timerConfig = { + OnBootSec = "0m"; + OnUnitInactiveSec = "30m"; + + AccuracySec = "1m"; + RandomizedDelaySec = "1m"; + }; + }; systemd.services."Jinja-Compose" = { - description = "Start Jinja-Compose project"; + description = "Update and start Jinja-Compose project"; + serviceConfig = { + Type = "oneshot"; + PrivateTmp = true; + User = "root"; + }; path = with pkgs; [ # The `docker-compose` helper script is written in `bash` (!) bash @@ -137,7 +154,5 @@ in /jc-config/docker-compose pull /jc-config/docker-compose up -d --wait ''; - # Start after login. - wantedBy = [ "multi-user.target" ]; }; }