danghungithp commited on
Commit
cb135fe
·
verified ·
1 Parent(s): f5014d1

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +31 -7
start.sh CHANGED
@@ -1,10 +1,34 @@
1
  #!/bin/bash
2
- echo "Starting Ollama..."
 
 
 
 
 
 
3
  ollama serve &
4
- echo "Waiting for Ollama to be ready..."
5
- until curl -s http://localhost:11434 > /dev/null; do
6
- echo "Ollama not ready yet, waiting..."
7
- sleep 1
 
 
 
 
 
 
 
 
 
 
 
 
8
  done
9
- echo "Ollama is ready, starting app.py..."
10
- python3 app.py
 
 
 
 
 
 
 
1
  #!/bin/bash
2
+
3
+ # Set environment variables for optimization
4
+ export OMP_NUM_THREADS=4
5
+ export MKL_NUM_THREADS=4
6
+ export CUDA_VISIBLE_DEVICES=0
7
+
8
+ # Start Ollama in the background
9
  ollama serve &
10
+
11
+ # Pull the model if not already present
12
+ if ! ollama list | grep -q "tinyllama"; then
13
+ ollama pull tinyllama
14
+ fi
15
+
16
+ # Wait for Ollama to start up
17
+ max_attempts=30
18
+ attempt=0
19
+ while ! curl -s http://localhost:11434/api/tags >/dev/null; do
20
+ sleep 1
21
+ attempt=$((attempt + 1))
22
+ if [ $attempt -eq $max_attempts ]; then
23
+ echo "Ollama failed to start within 30 seconds. Exiting."
24
+ exit 1
25
+ fi
26
  done
27
+
28
+ echo "Ollama is ready."
29
+
30
+ # Print the API URL
31
+ echo "API is running on: http://0.0.0.0:7860"
32
+
33
+ # Start the FastAPI server
34
+ uvicorn app:app --host 0.0.0.0 --port 7860 --workers 4 --limit-concurrency 20