File size: 596 Bytes
21ed284
 
d794f38
 
21ed284
 
 
 
 
 
 
 
daa46b4
21ed284
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# Start Ollama in the background
ollama serve &
#ollama serve --port 7860 --host 0.0.0.0 &
# Pull a small model (e.g., TinyLlama) if not present
if ! ollama list | grep -q "tinyllama"; then
    ollama pull tinyllama
fi

# Wait for Ollama to start (up to 30 seconds)
max_attempts=30
attempt=0
while ! curl -s http://localhost:7860/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