modules: use consul-ready when waiting for consul

This commit is contained in:
Max Headroom 2024-07-17 16:32:56 +02:00
parent d2ab37f3b1
commit 9aa1f29e24
3 changed files with 10 additions and 3 deletions

View file

@ -87,7 +87,8 @@ in
description = "Ascension for ${name}";
wantedBy = [ "multi-user.target" ];
inherit (asc) requiredBy before;
after = asc.after ++ (lib.optional asc.distributed "consul.service");
after = asc.after ++ (lib.optional asc.distributed "consul-ready.service");
requires = lib.optional asc.distributed "consul-ready.service";
serviceConfig.Type = "oneshot";
distributed.enable = asc.distributed;
script = ''

View file

@ -42,6 +42,10 @@ in
hasSpecialPrefix = elem (substring 0 1 ExecStart) [ "@" "-" ":" "+" "!" ];
in assert !hasSpecialPrefix; pkgs.writeTextDir "etc/systemd/system/${n}.service.d/distributed.conf" ''
[Unit]
Requires=consul-ready.service
After=consul-ready.service
[Service]
ExecStartPre=${waitForConsul} 'services/${n}%i'
ExecStart=

View file

@ -81,14 +81,16 @@ let
}.${mode};
value = {
direct = {
after = [ "consul.service" ];
after = [ "consul-ready.service" ];
requires = [ "consul-ready.service" ];
serviceConfig = {
ExecStartPost = register servicesJson;
ExecStopPost = deregister servicesJson;
};
};
external = {
after = [ "consul.service" "${unit}.service" ];
after = [ "consul-ready.service" "${unit}.service" ];
requires = [ "consul-ready.service" ];
wantedBy = [ "${unit}.service" ];
unitConfig.BindsTo = "${unit}.service";
serviceConfig = {