Arshit Malik commited on
Commit
8d8777e
·
1 Parent(s): aa49469

fix: move pkill to runtime, only rm cron files during build

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -7
  2. start.sh +14 -18
Dockerfile CHANGED
@@ -2,17 +2,13 @@ FROM ghcr.io/openclaw/openclaw:latest
2
 
3
  USER root
4
 
5
- # Kill the HuggingClaw health-check daemon that causes Space pauses
6
  RUN rm -f /etc/cron.d/*health* /etc/cron.d/*hc* 2>/dev/null; \
7
- rm -f /usr/local/bin/*health* /usr/local/bin/*hc* 2>/dev/null; \
8
- pkill -f health 2>/dev/null; \
9
- echo "Health daemon removed"
10
 
11
- # Install Ollama + deps
12
  RUN apt-get update && apt-get install -y curl nginx zstd cron procps git && rm -rf /var/lib/apt/lists/*
13
  RUN curl -fsSL https://ollama.com/install.sh | sh
14
-
15
- # Install huggingface_hub for model download
16
  RUN pip install --no-cache-dir huggingface_hub
17
 
18
  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
 
2
 
3
  USER root
4
 
5
+ # Remove health-check cron files (disable the daemon without killing processes)
6
  RUN rm -f /etc/cron.d/*health* /etc/cron.d/*hc* 2>/dev/null; \
7
+ rm -f /etc/cron.d/*hugging* 2>/dev/null; \
8
+ echo "Health cron files removed"
 
9
 
 
10
  RUN apt-get update && apt-get install -y curl nginx zstd cron procps git && rm -rf /var/lib/apt/lists/*
11
  RUN curl -fsSL https://ollama.com/install.sh | sh
 
 
12
  RUN pip install --no-cache-dir huggingface_hub
13
 
14
  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
start.sh CHANGED
@@ -1,6 +1,12 @@
1
  #!/bin/bash
2
  set -e
3
 
 
 
 
 
 
 
4
  echo "[boot] Pulling OpenClaw state from Dataset..."
5
  python3 -c "
6
  import sys, os; sys.path.insert(0, '/app')
@@ -63,7 +69,6 @@ git config --global user.name "YT Pipeline Bot"
63
  git config --global user.email "yt-pipe-bot@hf.space"
64
  git clone https://arshitmalik:${HF_TOKEN}@huggingface.co/spaces/arshitmalik/yt-flow /app/yt-flow 2>/dev/null || true
65
 
66
- # Backup cron every 15 min
67
  cat > /tmp/backup.sh << 'CRONEOF'
68
  #!/bin/bash
69
  python3 -c "
@@ -89,16 +94,12 @@ CRONEOF
89
  chmod +x /tmp/backup.sh
90
  echo "*/15 * * * * /tmp/backup.sh" | crontab -
91
 
92
- # Smart health proxy on 8080 — forwards to OpenClaw when ready, returns 200 otherwise
93
  python3 -c "
94
  import http.server, urllib.request
95
- HEALTH_PORT = 8080
96
- OPENCLAW_PORT = 8081
97
-
98
  class Proxy(http.server.BaseHTTPRequestHandler):
99
  def _forward(self, method):
100
  try:
101
- url = f'http://127.0.0.1:{OPENCLAW_PORT}{self.path}'
102
  data = None
103
  if method == 'POST':
104
  cl = int(self.headers.get('Content-Length', 0))
@@ -119,16 +120,13 @@ class Proxy(http.server.BaseHTTPRequestHandler):
119
  except Exception:
120
  self.send_response(200)
121
  self.end_headers()
122
- self.wfile.write(b'OpenClaw booting...')
123
-
124
  def do_GET(self): self._forward('GET')
125
  def do_POST(self): self._forward('POST')
126
  def log_message(self, *a): pass
127
-
128
- http.server.HTTPServer(('0.0.0.0', HEALTH_PORT), Proxy).serve_forever()
129
  " &
130
- PROXY_PID=$!
131
- echo "[boot] Health proxy PID: $PROXY_PID"
132
 
133
  echo "[boot] Starting nginx..."
134
  nginx
@@ -174,11 +172,9 @@ subprocess.run(["ollama", "create", "deepseek-qwen-14b", "-f", "/tmp/Modelfile"]
174
  Path(gguf_path).unlink()
175
  PYEOF
176
 
177
- echo "[boot] Starting OpenClaw gateway on port 8081..."
178
  openclaw gateway 2>&1 &
179
- OPENCLAW_PID=$!
180
- echo "[boot] OpenClaw PID: $OPENCLAW_PID"
181
-
182
- echo "[boot] All services running. Container will stay alive."
183
- wait $OPENCLAW_PID 2>/dev/null
184
  sleep infinity
 
1
  #!/bin/bash
2
  set -e
3
 
4
+ # Kill any leftover health daemon from the base image at runtime
5
+ pkill -f "health" 2>/dev/null || true
6
+ pkill -f "hc-" 2>/dev/null || true
7
+ crontab -r 2>/dev/null || true
8
+ echo "[boot] Health daemon silenced"
9
+
10
  echo "[boot] Pulling OpenClaw state from Dataset..."
11
  python3 -c "
12
  import sys, os; sys.path.insert(0, '/app')
 
69
  git config --global user.email "yt-pipe-bot@hf.space"
70
  git clone https://arshitmalik:${HF_TOKEN}@huggingface.co/spaces/arshitmalik/yt-flow /app/yt-flow 2>/dev/null || true
71
 
 
72
  cat > /tmp/backup.sh << 'CRONEOF'
73
  #!/bin/bash
74
  python3 -c "
 
94
  chmod +x /tmp/backup.sh
95
  echo "*/15 * * * * /tmp/backup.sh" | crontab -
96
 
 
97
  python3 -c "
98
  import http.server, urllib.request
 
 
 
99
  class Proxy(http.server.BaseHTTPRequestHandler):
100
  def _forward(self, method):
101
  try:
102
+ url = f'http://127.0.0.1:8081{self.path}'
103
  data = None
104
  if method == 'POST':
105
  cl = int(self.headers.get('Content-Length', 0))
 
120
  except Exception:
121
  self.send_response(200)
122
  self.end_headers()
123
+ self.wfile.write(b'YT Claw booting...')
 
124
  def do_GET(self): self._forward('GET')
125
  def do_POST(self): self._forward('POST')
126
  def log_message(self, *a): pass
127
+ http.server.HTTPServer(('0.0.0.0', 8080), Proxy).serve_forever()
 
128
  " &
129
+ echo "[boot] Smart proxy on :8080 → :8081"
 
130
 
131
  echo "[boot] Starting nginx..."
132
  nginx
 
172
  Path(gguf_path).unlink()
173
  PYEOF
174
 
175
+ echo "[boot] Starting OpenClaw gateway on :8081..."
176
  openclaw gateway 2>&1 &
177
+ echo "[boot] OpenClaw PID: $!"
178
+ echo "[boot] All services running."
179
+ wait $! 2>/dev/null
 
 
180
  sleep infinity