Wait for Ollama API during setup

This commit is contained in:
juvdiaz 2026-06-28 00:15:51 -06:00
parent 26be9bfb0c
commit 3c5dfd08c2
1 changed files with 12 additions and 2 deletions

14
jeannie
View File

@ -3395,6 +3395,7 @@ website_ollama_listen() {
local models_dir="${LAB_OLLAMA_MODELS_DIR:-/data/ollama/models}"
local dropin_dir="/etc/systemd/system/ollama.service.d"
local dropin_file="${dropin_dir}/homelab.conf"
local waited=0
require_debian_server "website-ollama-listen"
@ -3415,8 +3416,17 @@ website_ollama_listen() {
sudo systemctl restart ollama.service
sudo systemctl is-active --quiet ollama.service
echo "Ollama service is active. Verifying http://${bind_address%:*}:11434/api/tags..."
curl -fsS "http://127.0.0.1:11434/api/tags" >/dev/null
echo "Ollama service is active. Waiting for http://127.0.0.1:11434/api/tags..."
until curl -fsS --connect-timeout 2 --max-time 5 "http://127.0.0.1:11434/api/tags" >/dev/null 2>&1; do
waited=$((waited + 2))
if ((waited >= 60)); then
echo "Ollama service did not expose the local API after ${waited}s." >&2
echo "Recent service logs:" >&2
sudo journalctl -u ollama.service -n 80 --no-pager >&2 || true
exit 1
fi
sleep 2
done
echo "Ollama API is reachable on the Debian host."
}