modules: use consul-ready when waiting for consul
This commit is contained in:
parent
d2ab37f3b1
commit
9aa1f29e24
3 changed files with 10 additions and 3 deletions
|
@ -87,7 +87,8 @@ in
|
||||||
description = "Ascension for ${name}";
|
description = "Ascension for ${name}";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
inherit (asc) requiredBy before;
|
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";
|
serviceConfig.Type = "oneshot";
|
||||||
distributed.enable = asc.distributed;
|
distributed.enable = asc.distributed;
|
||||||
script = ''
|
script = ''
|
||||||
|
|
|
@ -42,6 +42,10 @@ in
|
||||||
|
|
||||||
hasSpecialPrefix = elem (substring 0 1 ExecStart) [ "@" "-" ":" "+" "!" ];
|
hasSpecialPrefix = elem (substring 0 1 ExecStart) [ "@" "-" ":" "+" "!" ];
|
||||||
in assert !hasSpecialPrefix; pkgs.writeTextDir "etc/systemd/system/${n}.service.d/distributed.conf" ''
|
in assert !hasSpecialPrefix; pkgs.writeTextDir "etc/systemd/system/${n}.service.d/distributed.conf" ''
|
||||||
|
[Unit]
|
||||||
|
Requires=consul-ready.service
|
||||||
|
After=consul-ready.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStartPre=${waitForConsul} 'services/${n}%i'
|
ExecStartPre=${waitForConsul} 'services/${n}%i'
|
||||||
ExecStart=
|
ExecStart=
|
||||||
|
|
|
@ -81,14 +81,16 @@ let
|
||||||
}.${mode};
|
}.${mode};
|
||||||
value = {
|
value = {
|
||||||
direct = {
|
direct = {
|
||||||
after = [ "consul.service" ];
|
after = [ "consul-ready.service" ];
|
||||||
|
requires = [ "consul-ready.service" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStartPost = register servicesJson;
|
ExecStartPost = register servicesJson;
|
||||||
ExecStopPost = deregister servicesJson;
|
ExecStopPost = deregister servicesJson;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
external = {
|
external = {
|
||||||
after = [ "consul.service" "${unit}.service" ];
|
after = [ "consul-ready.service" "${unit}.service" ];
|
||||||
|
requires = [ "consul-ready.service" ];
|
||||||
wantedBy = [ "${unit}.service" ];
|
wantedBy = [ "${unit}.service" ];
|
||||||
unitConfig.BindsTo = "${unit}.service";
|
unitConfig.BindsTo = "${unit}.service";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
|
Loading…
Reference in a new issue