docker-stack: add systemd timer
This commit is contained in:
parent
6f7bf47520
commit
af160ab156
1 changed files with 12 additions and 1 deletions
|
@ -168,6 +168,15 @@ let
|
|||
> $out
|
||||
'';
|
||||
|
||||
mkStackTimer = stackName: {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnBootSec = "5m";
|
||||
OnUnitActiveSec = "5m";
|
||||
Unit = "docker-stack-${stackName}.service";
|
||||
};
|
||||
};
|
||||
|
||||
mkStackService = stackName: stack:
|
||||
let
|
||||
escapedStackName = lib.escapeShellArg stackName;
|
||||
|
@ -175,6 +184,7 @@ let
|
|||
in
|
||||
{
|
||||
description = "Deploy ${escapedStackName} stack";
|
||||
enable = true;
|
||||
|
||||
after = [ "docker.service" "docker.socket" ];
|
||||
environment = proxyEnv;
|
||||
|
@ -200,7 +210,8 @@ in
|
|||
description = lib.mdDoc "Docker stacks to deploy using systemd services.";
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg.stacks != { }) {
|
||||
config = lib.mkIfattrNames (cfg.stacks != { }) {
|
||||
systemd.timers = lib.mapAttrs' (n: v: lib.nameValuePair "docker-stack-${n}" (mkStackTimer n)) cfg.stacks;
|
||||
systemd.services = lib.mapAttrs' (n: v: lib.nameValuePair "docker-stack-${n}" (mkStackService n v)) cfg.stacks;
|
||||
|
||||
virtualisation.docker = {
|
||||
|
|
Loading…
Reference in a new issue