From c11f143783c6bd0595ec1ba3df0ed36e4e813c47 Mon Sep 17 00:00:00 2001 From: Martin Nikov Date: Fri, 19 Jan 2024 18:24:23 +0200 Subject: [PATCH] config(modules/lido/withdrawals-automation): Define `ExecStartPre` with kapi-url healthcheck --- modules/lido/withdrawals-automation/default.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/lido/withdrawals-automation/default.nix b/modules/lido/withdrawals-automation/default.nix index b1a4133a..5fb62de8 100644 --- a/modules/lido/withdrawals-automation/default.nix +++ b/modules/lido/withdrawals-automation/default.nix @@ -82,6 +82,20 @@ serviceConfig = lib.mkMerge [ { Group = "lido"; + ExecStartPre = pkgs.writeShellScript "healthcheck.sh" '' + #!/usr/bin/env bash + set -euo pipefail + + while true; do + if ${lib.getExe pkgs.curl} -sSf ${cfg.args.kapi-url} > /dev/null; then + echo "${cfg.args.kapi-url} is online" + break + else + echo "${cfg.args.kapi-url} is offline, waiting..." + sleep 5 # Adjust the sleep duration as needed + fi + done + ''; ExecStart = lib.getExe (pkgs.writeShellApplication { name = "repl"; text = ''