tao-shen Claude Opus 4.6 commited on
Commit
3dc8487
Β·
1 Parent(s): baf6f79

fix: use /runlog endpoints (HF intercepts /logs and /api/*)

Browse files

HF's reverse proxy intercepts /logs and /api/* paths. Use /runlog
and /runlog/stream instead. Also remove test delay before nginx.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

ubuntu-server/nginx.conf CHANGED
@@ -33,16 +33,16 @@ http {
33
  proxy_send_timeout 86400;
34
  }
35
 
36
- # /api/logs β†’ full log file (static)
37
- # Note: /logs is intercepted by HF's proxy, so we use /api/logs
38
- location = /api/logs {
39
  default_type text/plain;
40
  add_header Cache-Control "no-cache, no-store";
41
  alias /var/log/huggingrun.log;
42
  }
43
 
44
- # /api/logs/stream β†’ SSE real-time log stream
45
- location /api/logs/stream {
46
  proxy_pass http://127.0.0.1:7863/stream;
47
  proxy_http_version 1.1;
48
  proxy_set_header Connection "";
 
33
  proxy_send_timeout 86400;
34
  }
35
 
36
+ # /runlog β†’ full log file (static)
37
+ # Note: /logs and /api/* are intercepted by HF's proxy
38
+ location = /runlog {
39
  default_type text/plain;
40
  add_header Cache-Control "no-cache, no-store";
41
  alias /var/log/huggingrun.log;
42
  }
43
 
44
+ # /runlog/stream β†’ SSE real-time log stream
45
+ location /runlog/stream {
46
  proxy_pass http://127.0.0.1:7863/stream;
47
  proxy_http_version 1.1;
48
  proxy_set_header Connection "";
ubuntu-server/start-server.sh CHANGED
@@ -103,6 +103,8 @@ log "[ubuntu] All processes:"
103
  ps aux --no-headers 2>/dev/null | awk '{printf "[ubuntu] %-8s PID=%-6s %s\n", $1, $2, $11}' | while IFS= read -r line; do log "$line"; done
104
 
105
  log "[ubuntu] ══ System ready ══"
 
 
106
 
107
  # ── Heartbeat (writes to logfile for /api/logs) ──────────────────
108
  (while true; do
@@ -111,9 +113,6 @@ log "[ubuntu] ══ System ready ══"
111
  done) &
112
 
113
  # ── Start nginx LAST β†’ opens port 7860 β†’ HF transitions to RUNNING ──
114
- # Delay nginx to keep container in STARTING state so SSE captures output
115
- log "[ubuntu] Delaying nginx by 30s to test HF SSE capture during STARTING..."
116
- sleep 30
117
  log "[ubuntu] Starting nginx on 0.0.0.0:7860 (HF will mark RUNNING) ..."
118
  nginx -g 'daemon off;' &
119
  NGINX_PID=$!
 
103
  ps aux --no-headers 2>/dev/null | awk '{printf "[ubuntu] %-8s PID=%-6s %s\n", $1, $2, $11}' | while IFS= read -r line; do log "$line"; done
104
 
105
  log "[ubuntu] ══ System ready ══"
106
+ log "[ubuntu] View logs: curl https://<space>.hf.space/runlog"
107
+ log "[ubuntu] Stream SSE: curl -N https://<space>.hf.space/runlog/stream"
108
 
109
  # ── Heartbeat (writes to logfile for /api/logs) ──────────────────
110
  (while true; do
 
113
  done) &
114
 
115
  # ── Start nginx LAST β†’ opens port 7860 β†’ HF transitions to RUNNING ──
 
 
 
116
  log "[ubuntu] Starting nginx on 0.0.0.0:7860 (HF will mark RUNNING) ..."
117
  nginx -g 'daemon off;' &
118
  NGINX_PID=$!