modules/consul-service-registry: limit number of retries for deregister
This commit is contained in:
parent
f423f868c5
commit
2ff899cd3e
1 changed files with 10 additions and 5 deletions
|
@ -7,15 +7,20 @@ let
|
||||||
|
|
||||||
consul = "${config.services.consul.package}/bin/consul";
|
consul = "${config.services.consul.package}/bin/consul";
|
||||||
|
|
||||||
writeLoopScript = name: cmd: pkgs.writeShellScript name ''
|
consulRegisterScript = pkgs.writeShellScript "consul-register" ''
|
||||||
while ! ${cmd}; do
|
while ! ${consul} services register "$1"; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
consulRegisterScript = writeLoopScript "consul-register" ''${consul} services register "$1"'';
|
consulDeregisterScript = pkgs.writeShellScript "consul-deregister" ''
|
||||||
|
for i in {1..5}; do
|
||||||
consulDeregisterScript = writeLoopScript "consul-deregister" ''${consul} services deregister "$1"'';
|
if ${consul} services deregister "$1"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
|
||||||
register = servicesJson: "${consulRegisterScript} ${servicesJson}";
|
register = servicesJson: "${consulRegisterScript} ${servicesJson}";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue