From 0c32557ee59456d72191f1659405d4df6357c911 Mon Sep 17 00:00:00 2001 From: Lan Tian Date: Mon, 2 Dec 2024 02:18:39 -0800 Subject: [PATCH] uni-api, llama-sakura-llm: use curl retry to check for service startup --- nixos/optional-apps/llama-sakura-llm.nix | 11 +++++++---- nixos/optional-apps/uni-api.nix | 11 +++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/nixos/optional-apps/llama-sakura-llm.nix b/nixos/optional-apps/llama-sakura-llm.nix index b15ae794..1adecd7b 100644 --- a/nixos/optional-apps/llama-sakura-llm.nix +++ b/nixos/optional-apps/llama-sakura-llm.nix @@ -76,10 +76,13 @@ in path = with pkgs; [ curl ]; postStart = '' - while ! curl -f http://${cfg.host}:${builtins.toString cfg.port}/health; do - echo "Still waiting for llama-cpp to start" - sleep 1 - done + curl \ + --fail \ + --retry 30 \ + --retry-delay 5 \ + --retry-max-time 120 \ + --retry-all-errors \ + http://${cfg.host}:${builtins.toString cfg.port}/health ''; serviceConfig = LT.serviceHarden // { diff --git a/nixos/optional-apps/uni-api.nix b/nixos/optional-apps/uni-api.nix index 3de389e0..74dd3c17 100644 --- a/nixos/optional-apps/uni-api.nix +++ b/nixos/optional-apps/uni-api.nix @@ -162,6 +162,17 @@ in exec ${pkgs.nur-xddxdd.uni-api}/bin/uni-api ''; + postStart = '' + ${pkgs.curl}/bin/curl \ + --fail \ + --retry 10 \ + --retry-delay 5 \ + --retry-max-time 60 \ + --retry-all-errors \ + -H "Authorization: Bearer $(cat ${config.age.secrets.uni-api-admin-api-key.path})" \ + http://uni-api.localhost/v1/models + ''; + serviceConfig = LT.serviceHarden // { Restart = "always"; RestartSec = "3";