Echo-ai commited on
Commit
21ed284
·
verified ·
1 Parent(s): dad2de8

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +24 -5
start.sh CHANGED
@@ -1,5 +1,24 @@
1
- #!/bin/sh
2
- nohup ollama serve > 2>&1 &
3
- sleep 10
4
- ollama pull tinyllama
5
- uvicorn app:app --host 0.0.0.0 --port 7860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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