Update start.sh
Browse files
start.sh
CHANGED
@@ -1,10 +1,34 @@
|
|
1 |
#!/bin/bash
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
ollama serve &
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
done
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|