Skip to content

Commit

Permalink
uni-api, llama-sakura-llm: use curl retry to check for service startup
Browse files Browse the repository at this point in the history
  • Loading branch information
xddxdd committed Dec 2, 2024
1 parent 1488f6a commit 0c32557
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 7 additions & 4 deletions nixos/optional-apps/llama-sakura-llm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 // {
Expand Down
11 changes: 11 additions & 0 deletions nixos/optional-apps/uni-api.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 0c32557

Please sign in to comment.