mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 19:29:47 +01:00
unison: better retry/restart reporting failures
The service was never marked with a failed state with the previous approach, which could lead broken synchronisation pair states to go undetected. The module now uses a timer instead of unlimited restarts, which does not have this issue.
This commit is contained in:
parent
20552eb59b
commit
91b4c632e6
1 changed files with 13 additions and 13 deletions
|
@ -65,9 +65,10 @@ let
|
||||||
|
|
||||||
serialiseArgs = args: concatStringsSep " " (mapAttrsToList serialiseArg args);
|
serialiseArgs = args: concatStringsSep " " (mapAttrsToList serialiseArg args);
|
||||||
|
|
||||||
|
unitName = name: "unison-pair-${name}";
|
||||||
|
|
||||||
makeDefs = gen:
|
makeDefs = gen:
|
||||||
mapAttrs'
|
mapAttrs' (name: pairCfg: nameValuePair (unitName name) (gen name pairCfg))
|
||||||
(name: pairCfg: nameValuePair "unison-pair-${name}" (gen name pairCfg))
|
|
||||||
cfg.pairs;
|
cfg.pairs;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
@ -106,19 +107,10 @@ in {
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.user.services = makeDefs (name: pairCfg: {
|
systemd.user.services = makeDefs (name: pairCfg: {
|
||||||
Unit = {
|
Unit.Description = "Unison pair sync (${name})";
|
||||||
Description = "Unison pair sync (${name})";
|
|
||||||
# Retry forever, useful in case of network disruption.
|
|
||||||
StartLimitIntervalSec = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
Restart = "always";
|
|
||||||
RestartSec = 60;
|
|
||||||
|
|
||||||
CPUSchedulingPolicy = "idle";
|
CPUSchedulingPolicy = "idle";
|
||||||
IOSchedulingClass = "idle";
|
IOSchedulingClass = "idle";
|
||||||
|
|
||||||
Environment = [ "UNISON='${toString pairCfg.stateDirectory}'" ];
|
Environment = [ "UNISON='${toString pairCfg.stateDirectory}'" ];
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${cfg.package}/bin/unison \
|
${cfg.package}/bin/unison \
|
||||||
|
@ -126,8 +118,16 @@ in {
|
||||||
${strings.concatMapStringsSep " " escapeShellArg pairCfg.roots}
|
${strings.concatMapStringsSep " " escapeShellArg pairCfg.roots}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
|
||||||
Install = { WantedBy = [ "default.target" ]; };
|
systemd.user.timers = makeDefs (name: pairCfg: {
|
||||||
|
Unit.Description = "Unison pair sync auto-restart (${name})";
|
||||||
|
Install.WantedBy = [ "timers.target" ];
|
||||||
|
Timer = {
|
||||||
|
Unit = "${unitName name}.service";
|
||||||
|
OnActiveSec = 1;
|
||||||
|
OnUnitInactiveSec = 60;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue