Wait for Ollama API during setup
This commit is contained in:
parent
26be9bfb0c
commit
3c5dfd08c2
14
jeannie
14
jeannie
|
|
@ -3395,6 +3395,7 @@ website_ollama_listen() {
|
||||||
local models_dir="${LAB_OLLAMA_MODELS_DIR:-/data/ollama/models}"
|
local models_dir="${LAB_OLLAMA_MODELS_DIR:-/data/ollama/models}"
|
||||||
local dropin_dir="/etc/systemd/system/ollama.service.d"
|
local dropin_dir="/etc/systemd/system/ollama.service.d"
|
||||||
local dropin_file="${dropin_dir}/homelab.conf"
|
local dropin_file="${dropin_dir}/homelab.conf"
|
||||||
|
local waited=0
|
||||||
|
|
||||||
require_debian_server "website-ollama-listen"
|
require_debian_server "website-ollama-listen"
|
||||||
|
|
||||||
|
|
@ -3415,8 +3416,17 @@ website_ollama_listen() {
|
||||||
sudo systemctl restart ollama.service
|
sudo systemctl restart ollama.service
|
||||||
sudo systemctl is-active --quiet ollama.service
|
sudo systemctl is-active --quiet ollama.service
|
||||||
|
|
||||||
echo "Ollama service is active. Verifying http://${bind_address%:*}:11434/api/tags..."
|
echo "Ollama service is active. Waiting for http://127.0.0.1:11434/api/tags..."
|
||||||
curl -fsS "http://127.0.0.1:11434/api/tags" >/dev/null
|
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."
|
echo "Ollama API is reachable on the Debian host."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue