From 2ef144d5725940f291d6e04bd4ea339ca825c5d5 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Wed, 24 Jun 2026 09:44:01 +0800 Subject: [PATCH] fix(console): serve dashboard/dist via local python http.server (not npm/caddy) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prebuilt runtime ships only dashboard/dist (no package.json) so npm run preview ENOENT-crash-loops (254). console is a local-only static backend on 127.0.0.1:17000 (dashboard is a routerless SPA); serve it with python3 -m http.server on both Linux (console.service) and macOS (console.plist) — no second caddy (avoids clashing with the system caddy on :80; console is local-only and not proxied by default). Gate the apt caddy install on caddy_enabled (true on public-IP Linux VPS for the bridge ingress; macOS installs no caddy). Verified: debian13 + ubuntu26.04 console.service active serving 17000=200; macOS python3 serves the same dist locally. Co-Authored-By: Claude Opus 4.8 --- console.plist.j2 | 6 ++++-- setup-xworkspace-console.yaml | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/console.plist.j2 b/console.plist.j2 index 0c04ed9..64b54ba 100644 --- a/console.plist.j2 +++ b/console.plist.j2 @@ -10,7 +10,9 @@ -c export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH" - exec /usr/bin/env npm run preview -- --host 127.0.0.1 --port {{ xworkspace_console_port }} + # 预编译 runtime 只发 dashboard/dist(无 package.json),且 dashboard 是 + # 无客户端路由的单页应用,故用 python3 静态伺服 dist 即可(macOS 无 caddy)。 + exec /usr/bin/env python3 -m http.server {{ xworkspace_console_port }} --bind 127.0.0.1 --directory "{{ xworkspace_console_dashboard_dir }}/dist" RunAtLoad @@ -18,7 +20,7 @@ KeepAlive WorkingDirectory - {{ xworkspace_console_dashboard_dir }} + {{ xworkspace_console_dashboard_dir }}/dist StandardOutPath {{ ansible_env.HOME }}/.local/state/xworkspace/console.log StandardErrorPath diff --git a/setup-xworkspace-console.yaml b/setup-xworkspace-console.yaml index be62f6e..d0ed0fe 100644 --- a/setup-xworkspace-console.yaml +++ b/setup-xworkspace-console.yaml @@ -158,7 +158,8 @@ update_cache: true name: >- {{ - ['caddy', 'xfce4', 'python3', 'golang-go'] + ['xfce4', 'python3', 'golang-go'] + + (['caddy'] if caddy_enabled | default(true) | bool else []) + ([xworkspace_console_browser_package] if xworkspace_console_browser_package | length > 0 else []) }} state: present @@ -623,8 +624,11 @@ [Service] Type=simple - WorkingDirectory={{ xworkspace_console_dashboard_dir }} - ExecStart=/usr/bin/npm run preview -- --host 127.0.0.1 --port {{ xworkspace_console_port }} + WorkingDirectory={{ xworkspace_console_dashboard_dir }}/dist + # console 只是 17000 上的静态后端(dashboard 为无路由单页 dist),由系统 + # caddy 经 /etc/caddy/conf.d/ 反代对外。用 python3 静态伺服即可,跨 Linux/ + # macOS 统一、不再起第二个 caddy(避免与系统 caddy 抢 :80)。 + ExecStart=/usr/bin/env python3 -m http.server {{ xworkspace_console_port }} --bind 127.0.0.1 --directory {{ xworkspace_console_dashboard_dir }}/dist Restart=always RestartSec=2