Spaces:
Paused
Paused
Arshit Malik commited on
Commit ·
4d9a3de
1
Parent(s): 1b1a273
fix: install tenacity, proxy health server handles OpenClaw crashes gracefully
Browse files- Dockerfile +1 -1
- start.sh +35 -17
Dockerfile
CHANGED
|
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y \
|
|
| 6 |
|
| 7 |
RUN curl -fsSL https://ollama.com/install.sh | sh
|
| 8 |
|
| 9 |
-
RUN pip install --no-cache-dir openclaw huggingface_hub
|
| 10 |
|
| 11 |
RUN printf 'server {\n listen 7860;\n location / {\n proxy_pass http://127.0.0.1:8080;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection "upgrade";\n proxy_set_header Host $host;\n }\n}\n' > /etc/nginx/sites-available/default
|
| 12 |
|
|
|
|
| 6 |
|
| 7 |
RUN curl -fsSL https://ollama.com/install.sh | sh
|
| 8 |
|
| 9 |
+
RUN pip install --no-cache-dir tenacity openclaw huggingface_hub
|
| 10 |
|
| 11 |
RUN printf 'server {\n listen 7860;\n location / {\n proxy_pass http://127.0.0.1:8080;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection "upgrade";\n proxy_set_header Host $host;\n }\n}\n' > /etc/nginx/sites-available/default
|
| 12 |
|
start.sh
CHANGED
|
@@ -88,14 +88,41 @@ CRONEOF
|
|
| 88 |
chmod +x /tmp/backup.sh
|
| 89 |
echo "*/15 * * * * /tmp/backup.sh" | crontab -
|
| 90 |
|
|
|
|
| 91 |
python3 -c "
|
| 92 |
-
|
| 93 |
-
class H(BaseHTTPRequestHandler):
|
| 94 |
def do_GET(self):
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
" &
|
| 98 |
HEALTH_PID=$!
|
|
|
|
| 99 |
|
| 100 |
echo "[boot] Starting nginx..."
|
| 101 |
nginx
|
|
@@ -112,7 +139,7 @@ for i in $(seq 1 30); do
|
|
| 112 |
sleep 2
|
| 113 |
done
|
| 114 |
|
| 115 |
-
echo "[boot] Building DeepSeek R1 Distill Qwen 14B IQ2_XS
|
| 116 |
python3 << PYEOF
|
| 117 |
import subprocess, sys, os
|
| 118 |
from pathlib import Path
|
|
@@ -141,20 +168,11 @@ subprocess.run(["ollama", "create", "deepseek-qwen-14b", "-f", "/tmp/Modelfile"]
|
|
| 141 |
Path(gguf_path).unlink()
|
| 142 |
PYEOF
|
| 143 |
|
| 144 |
-
echo "[boot] Starting OpenClaw gateway..."
|
| 145 |
python3 -m openclaw gateway &
|
| 146 |
OPENCLAW_PID=$!
|
|
|
|
| 147 |
|
| 148 |
-
echo "[boot]
|
| 149 |
-
for i in $(seq 1 30); do
|
| 150 |
-
if curl -sf http://127.0.0.1:8080/health > /dev/null 2>&1; then
|
| 151 |
-
echo "[boot] OpenClaw gateway ready after ${i}s"
|
| 152 |
-
break
|
| 153 |
-
fi
|
| 154 |
-
sleep 2
|
| 155 |
-
done
|
| 156 |
-
|
| 157 |
-
kill $HEALTH_PID 2>/dev/null
|
| 158 |
-
echo "[boot] Deployment complete. PID: $OPENCLAW_PID"
|
| 159 |
wait $OPENCLAW_PID 2>/dev/null
|
| 160 |
sleep infinity
|
|
|
|
| 88 |
chmod +x /tmp/backup.sh
|
| 89 |
echo "*/15 * * * * /tmp/backup.sh" | crontab -
|
| 90 |
|
| 91 |
+
# Health server stays alive FOREVER — we proxy to OpenClaw when it's up
|
| 92 |
python3 -c "
|
| 93 |
+
import http.server, urllib.request, os
|
| 94 |
+
class H(http.server.BaseHTTPRequestHandler):
|
| 95 |
def do_GET(self):
|
| 96 |
+
try:
|
| 97 |
+
r = urllib.request.urlopen('http://127.0.0.1:8080' + self.path, timeout=5)
|
| 98 |
+
self.send_response(r.status)
|
| 99 |
+
self.send_header('Content-Type', r.headers.get('Content-Type','text/plain'))
|
| 100 |
+
self.end_headers()
|
| 101 |
+
self.wfile.write(r.read())
|
| 102 |
+
except:
|
| 103 |
+
self.send_response(200)
|
| 104 |
+
self.end_headers()
|
| 105 |
+
self.wfile.write(b'OpenClaw starting...')
|
| 106 |
+
def do_POST(self):
|
| 107 |
+
try:
|
| 108 |
+
data = self.rfile.read(int(self.headers.get('Content-Length',0)))
|
| 109 |
+
r = urllib.request.urlopen(urllib.request.Request(
|
| 110 |
+
'http://127.0.0.1:8080' + self.path, data=data,
|
| 111 |
+
headers={k:v for k,v in self.headers.items()}
|
| 112 |
+
), timeout=30)
|
| 113 |
+
self.send_response(r.status)
|
| 114 |
+
self.send_header('Content-Type', r.headers.get('Content-Type','text/plain'))
|
| 115 |
+
self.end_headers()
|
| 116 |
+
self.wfile.write(r.read())
|
| 117 |
+
except:
|
| 118 |
+
self.send_response(502)
|
| 119 |
+
self.end_headers()
|
| 120 |
+
self.wfile.write(b'Gateway not ready')
|
| 121 |
+
def log_message(self,*a): pass
|
| 122 |
+
http.server.HTTPServer(('0.0.0.0', 8080), H).serve_forever()
|
| 123 |
" &
|
| 124 |
HEALTH_PID=$!
|
| 125 |
+
echo "[boot] Health proxy PID: $HEALTH_PID"
|
| 126 |
|
| 127 |
echo "[boot] Starting nginx..."
|
| 128 |
nginx
|
|
|
|
| 139 |
sleep 2
|
| 140 |
done
|
| 141 |
|
| 142 |
+
echo "[boot] Building DeepSeek R1 Distill Qwen 14B IQ2_XS..."
|
| 143 |
python3 << PYEOF
|
| 144 |
import subprocess, sys, os
|
| 145 |
from pathlib import Path
|
|
|
|
| 168 |
Path(gguf_path).unlink()
|
| 169 |
PYEOF
|
| 170 |
|
| 171 |
+
echo "[boot] Starting OpenClaw gateway on port 8081..."
|
| 172 |
python3 -m openclaw gateway &
|
| 173 |
OPENCLAW_PID=$!
|
| 174 |
+
echo "[boot] OpenClaw PID: $OPENCLAW_PID"
|
| 175 |
|
| 176 |
+
echo "[boot] Deployment complete. Sleeping forever..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
wait $OPENCLAW_PID 2>/dev/null
|
| 178 |
sleep infinity
|