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
|
> $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
mkStackTimer = stackName: {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnBootSec = "5m";
|
||||||
|
OnUnitActiveSec = "5m";
|
||||||
|
Unit = "docker-stack-${stackName}.service";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
mkStackService = stackName: stack:
|
mkStackService = stackName: stack:
|
||||||
let
|
let
|
||||||
escapedStackName = lib.escapeShellArg stackName;
|
escapedStackName = lib.escapeShellArg stackName;
|
||||||
|
@ -175,6 +184,7 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
description = "Deploy ${escapedStackName} stack";
|
description = "Deploy ${escapedStackName} stack";
|
||||||
|
enable = true;
|
||||||
|
|
||||||
after = [ "docker.service" "docker.socket" ];
|
after = [ "docker.service" "docker.socket" ];
|
||||||
environment = proxyEnv;
|
environment = proxyEnv;
|
||||||
|
@ -200,7 +210,8 @@ in
|
||||||
description = lib.mdDoc "Docker stacks to deploy using systemd services.";
|
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;
|
systemd.services = lib.mapAttrs' (n: v: lib.nameValuePair "docker-stack-${n}" (mkStackService n v)) cfg.stacks;
|
||||||
|
|
||||||
virtualisation.docker = {
|
virtualisation.docker = {
|
||||||
|
|
Loading…
Reference in a new issue