BIBLETUM commited on
Commit
f342f99
·
verified ·
1 Parent(s): 8f3a9b0

Create start.sh

Browse files
Files changed (1) hide show
  1. start.sh +29 -0
start.sh ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ MODEL_NAME="${MODEL_NAME:-qwen2.5:7b-instruct-q4_K_M}"
5
+ OLLAMA_URL="${OLLAMA_URL:-http://127.0.0.1:11434}"
6
+
7
+ # Start Ollama server in background
8
+ ollama serve > /tmp/ollama.log 2>&1 &
9
+ OLLAMA_PID=$!
10
+
11
+ # Wait until Ollama is ready
12
+ python3 - << 'PY'
13
+ import time, urllib.request
14
+ url = "http://127.0.0.1:11434/api/tags"
15
+ for _ in range(120):
16
+ try:
17
+ urllib.request.urlopen(url, timeout=1).read()
18
+ print("Ollama is up")
19
+ raise SystemExit(0)
20
+ except Exception:
21
+ time.sleep(1)
22
+ raise SystemExit("Ollama did not start")
23
+ PY
24
+
25
+ # Pull model (first run will download it)
26
+ ollama pull "${MODEL_NAME}"
27
+
28
+ # Start Gradio app
29
+ exec python3 /app/app.py