Echo-ai commited on
Commit
3e9fba9
·
verified ·
1 Parent(s): 73c65e6

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +18 -2
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
- # Start Ollama on port 7860 in the foreground
8
- exec ollama serve --port 7860 --host 0.0.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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