Spaces:
Paused
Paused
Echo-ai
commited on
Update start.sh
Browse files
start.sh
CHANGED
|
@@ -1,8 +1,24 @@
|
|
| 1 |
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
| 2 |
# Pull a small model (e.g., TinyLlama) if not present
|
| 3 |
if ! ollama list | grep -q "tinyllama"; then
|
| 4 |
ollama pull tinyllama
|
| 5 |
fi
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
+
# Start Ollama in the background
|
| 3 |
+
ollama serve &
|
| 4 |
+
|
| 5 |
# Pull a small model (e.g., TinyLlama) if not present
|
| 6 |
if ! ollama list | grep -q "tinyllama"; then
|
| 7 |
ollama pull tinyllama
|
| 8 |
fi
|
| 9 |
|
| 10 |
+
# Wait for Ollama to start (up to 30 seconds)
|
| 11 |
+
max_attempts=30
|
| 12 |
+
attempt=0
|
| 13 |
+
while ! curl -s http://localhost:11434/api/tags >/dev/null; do
|
| 14 |
+
sleep 1
|
| 15 |
+
attempt=$((attempt + 1))
|
| 16 |
+
if [ $attempt -eq $max_attempts ]; then
|
| 17 |
+
echo "Ollama failed to start within 30 seconds. Exiting."
|
| 18 |
+
exit 1
|
| 19 |
+
fi
|
| 20 |
+
done
|
| 21 |
+
echo "Ollama is ready."
|
| 22 |
+
|
| 23 |
+
# Start the FastAPI server
|
| 24 |
+
uvicorn app:app --host 0.0.0.0 --port 7860
|