Spaces:
Sleeping
Sleeping
fix: use /runlog endpoints (HF intercepts /logs and /api/*)
Browse filesHF'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 |
-
# /
|
| 37 |
-
# Note: /logs
|
| 38 |
-
location = /
|
| 39 |
default_type text/plain;
|
| 40 |
add_header Cache-Control "no-cache, no-store";
|
| 41 |
alias /var/log/huggingrun.log;
|
| 42 |
}
|
| 43 |
|
| 44 |
-
# /
|
| 45 |
-
location /
|
| 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=$!
|