Spaces:
Paused
Paused
fix: noVNC run in foreground with --web; dbus optional; add --wait-url for poll-without-token; doc PUSH_DEBUG
Browse filesFiles changed (3)
44 unmodified lines454647484950515 unmodified lines5758596061626317 unmodified lines818283848586878889909144 unmodified lines`--space-id` 默认是 `tao-shen/HuggingRun`,可省略。### 2.3 等 RUNNING 后跑完整测试(一键「远端是否成功」)```bash# Demo 或默认 Space5 unmodified lines--expect noVNC```脚本会先轮询直到 Space 状态为 RUNNING,再跑:基础 GET、压力请求、多轮持久化检查。**全部通过才 exit 0**,任一失败则 exit 1,便于脚本化「只有远端成功才算数」。### 2.4 不等待、直接测当前页面(Space 已 RUNNING 时)17 unmodified linesHF_TOKEN=xxx python3 scripts/monitor_and_test.py --wait-running --test --url https://tao-shen-huggingrun.hf.space --expect noVNC```3. 若 **测试失败**:用 `--logs run` 看容器内报错,修代码后:```bashgit add -A && git commit -m "fix: ..." && git push origin main```然后重复 1–2,直到测试全部通过。---44 unmodified lines4546474849505152535 unmodified lines59606162636465666768697071727317 unmodified lines91929394959697989910010144 unmodified lines`--space-id` 默认是 `tao-shen/HuggingRun`,可省略。### 2.3 等 RUNNING / 等 URL 就绪后跑完整测试(一键「远端是否成功」)**方式 A:有 HF_TOKEN 时**(推荐,可看 API 状态)```bash# Demo 或默认 Space5 unmodified lines--expect noVNC```**方式 B:无 HF_TOKEN 时**(只轮询 URL 直到页面出现期望内容)```bashpython3 scripts/monitor_and_test.py --wait-url --test \--url https://你的用户名-你的Space名.hf.space \--expect noVNC --max-wait 900```脚本会先轮询直到 GET 200 且 body 含 `noVNC`(或你给的 `--expect`),再跑:基础 GET、压力请求、多轮持久化检查。**全部通过才 exit 0**,任一失败则 exit 1。### 2.4 不等待、直接测当前页面(Space 已 RUNNING 时)17 unmodified linesHF_TOKEN=xxx python3 scripts/monitor_and_test.py --wait-running --test --url https://tao-shen-huggingrun.hf.space --expect noVNC```3. 若 **测试失败或一直 503**:用 `--logs run`(以及 `--logs build`)看容器内报错,修代码后:```bashgit add -A && git commit -m "fix: ..." && git push origin main```然后重复 1–2,直到测试全部通过。**只有远端全部通过才算数。**---
34 unmodified lines3536373839404112 unmodified lines54555657585994 unmodified lines1541551561571581598 unmodified lines16816917017117217334 unmodified linesdef wait_running(max_wait_sec=600, poll_interval=15):"""轮询直到 stage == RUNNING 或超时。"""start = time.time()while (time.time() - start) < max_wait_sec:rt, err = get_runtime()12 unmodified linesreturn Falsedef http_get(url, timeout=30, retries=3, retry_delay=2):"""GET url; retry on 502/503/timeout/connection errors (generic HF robustness)."""last_status, last_body, last_err = None, "", None94 unmodified linesp.add_argument("--max-wait", type=int, default=600)p.add_argument("--expect", action="append", dest="expect_substrings",help="Expected substring(s) in response body (basic test). Can repeat. Default: HuggingRun, Run anything")args = p.parse_args()SPACE_ID = args.space_idAPP_URL = args.url.rstrip("/")8 unmodified linesif not ok:sys.exit(1)if args.test:print(f"[test] Target: {APP_URL}")if not test_basic(APP_URL, expect_substrings=expect_substrings):34 unmodified lines3536373839404112 unmodified lines5455565758596061626364656667686970717273747594 unmodified lines1701711721731741751761778 unmodified lines18618718818919019119219319419519619734 unmodified linesdef wait_running(max_wait_sec=600, poll_interval=15):"""轮询直到 stage == RUNNING 或超时。需 HF_TOKEN。"""start = time.time()while (time.time() - start) < max_wait_sec:rt, err = get_runtime()12 unmodified linesreturn Falsedef wait_url(url, expect_substrings=None, max_wait_sec=900, poll_interval=20):"""轮询 URL 直到 GET 200 且 body 含任一 expect_substrings;无 HF_TOKEN 时用。"""if expect_substrings is None:expect_substrings = ("HuggingRun", "Run anything", "noVNC")start = time.time()while (time.time() - start) < max_wait_sec:status, body = http_get(url, timeout=30)if status == 200 and any(s in body for s in expect_substrings):print(f"[monitor] URL ready: {url}")return Trueprint(f"[monitor] URL not ready: status={status}, waiting {poll_interval}s ...")time.sleep(poll_interval)print("[monitor] Timeout waiting for URL content")return Falsedef http_get(url, timeout=30, retries=3, retry_delay=2):"""GET url; retry on 502/503/timeout/connection errors (generic HF robustness)."""last_status, last_body, last_err = None, "", None94 unmodified linesp.add_argument("--max-wait", type=int, default=600)p.add_argument("--expect", action="append", dest="expect_substrings",help="Expected substring(s) in response body (basic test). Can repeat. Default: HuggingRun, Run anything")p.add_argument("--wait-url", action="store_true",help="Poll URL until 200 and body contains one of --expect (no HF_TOKEN needed)")args = p.parse_args()SPACE_ID = args.space_idAPP_URL = args.url.rstrip("/")8 unmodified linesif not ok:sys.exit(1)if args.wait_url:ok = wait_url(APP_URL, expect_substrings=expect_substrings or ("HuggingRun", "Run anything", "noVNC"),max_wait_sec=args.max_wait, poll_interval=20)if not ok:sys.exit(1)if args.test:print(f"[test] Target: {APP_URL}")if not test_basic(APP_URL, expect_substrings=expect_substrings):
19 unmodified lines20212223242526273 unmodified lines3132333435363738394019 unmodified linesXVFB_PID=$!sleep 2# Start dbus for session (user session only; no system dbus as we run as non-root)dbus-daemon --session# Start XFCE (lightweight)startxfce4 &3 unmodified lines# x11vnc: share display :99 on port 5901x11vnc -display "$DISPLAY" -rfbport "$VNC_PORT" -forever -shared -noxdamage -bg# noVNC: web on 7860, proxy to VNCif [ -x /opt/noVNC/utils/novnc_proxy ]; then/opt/noVNC/utils/novnc_proxy --listen "$NOVNC_PORT" --vnc "localhost:$VNC_PORT"else# Fallback: websockify + simple http serve(cd /opt/noVNC && ./utils/novnc_proxy --listen "$NOVNC_PORT" --vnc "localhost:$VNC_PORT")fi19 unmodified lines20212223242526273 unmodified lines313233343519 unmodified linesXVFB_PID=$!sleep 2# Start dbus for session (optional; avoid exit on failure so noVNC can still serve)dbus-daemon --session 2>/dev/null || true# Start XFCE (lightweight)startxfce4 &3 unmodified lines# x11vnc: share display :99 on port 5901x11vnc -display "$DISPLAY" -rfbport "$VNC_PORT" -forever -shared -noxdamage -bg# noVNC: must run in foreground so container stays alive; serve web from /opt/noVNCexec /bin/bash -c "cd /opt/noVNC && exec ./utils/novnc_proxy --listen $NOVNC_PORT --vnc localhost:$VNC_PORT --web /opt/noVNC"
docs/PUSH_DEBUG.md+14-4
scripts/monitor_and_test.py+25-1
ubuntu-desktop/start-desktop.sh+4-9