API-ollama / start.sh
YussefGAFeer's picture
Update start.sh
b7ee572 verified
raw
history blame contribute delete
630 Bytes
#!/bin/bash
# Start Ollama in the background
ollama serve &
# Pull a small model (e.g., TinyLlama) if not present
if ! ollama list | grep -q "deepseek-r1:7b"; then
ollama pull deepseek-r1:7b
clear
ollama list
fi
# Wait for Ollama to start (up to 30 seconds)
max_attempts=30
attempt=0
while ! curl -s http://localhost:11434/api/tags >/dev/null; do
sleep 1
attempt=$((attempt + 1))
if [ $attempt -eq $max_attempts ]; then
echo "Ollama failed to start within 30 seconds. Exiting."
exit 1
fi
done
echo "Ollama is ready."
# Start the FastAPI server
uvicorn app:app --host 0.0.0.0 --port 7860