48a6166a570cbfe9eb323b4b55c40de60b906898
2 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
41a921b3c2 |
fix(dashboard): live logs via SSE, comfy types, plain-text parsing, debug endpoint
## User-reported issues addressed
### 1. Logs show literal \\n (and don't update live)
- Old impl: GET /api/services/[role] returned a JSON snapshot {logs: '...'}
with embedded \\n escape sequences that the UI rendered as plain text.
Plus it wasn't actually streaming — fetch returned the whole body at once.
- New: GET /api/services/[role]/stream — proper Server-Sent Events endpoint.
Emits one `log` event per line with {stream: stdout|stderr, line, ts}.
Uses a line buffer so partial chunks don't get split mid-line.
Client opens `new EventSource(...)` instead of fetch — gets genuine live
updates (docker logs -f --tail 300 --timestamps).
- Added keep-alive comment every 15s for proxies that kill idle SSE.
### 2. 'Llama Dashboard' → 'GPU Node Dashboard'
- Renamed everywhere (browser title, header, footer)
- The dashboard now manages llama + comfy + system + services, so the old
name was misleading.
### 3. Models not visible (llama + comfy)
- Root cause hypothesis: empty HOST_PROJECT_PATH → compose resolves
${HOST_PROJECT_PATH:-./} to './' relative to compose CWD inside the
dashboard container, so volume mounts point to a path that doesn't exist
on the host.
- Added /api/debug endpoint that returns:
* All env vars the dashboard sees (PROJECT_DIR, HOST_PROJECT_PATH,
LLAMA_MODELS_DIR, NODE_INSTANCE, SSH_ROLE, TAILSCALE_HOSTNAME)
* Which paths exist (PROJECT_DIR, LLAMA_MODELS_DIR, comfy models dir)
* Directory listings of each (so you can see what's actually there)
* Contents of .env (so you can verify HOST_PROJECT_PATH was set)
* Existence of dashboard-config.json
- This endpoint is for diagnosing 'models not visible' issues — call
`curl http://gpu-node:8090/api/debug` after deployment.
### 4. Comfy models parsing
- worker.py `list` and `queue` commands output human-readable text, not
JSON. The dashboard was trying to JSON.parse the output and silently
returning empty arrays.
- Added --json flag to both commands (worker.py):
* `worker.py list [type] --json` → {models: [{type, filename, sizeBytes}], total, totalBytes}
* `worker.py queue --json` → {jobs: [...]}
* `worker.py types` → ["checkpoints", "loras", ...] (new command)
- Updated dashboard to use --json everywhere.
### 5. Comfy model types — couldn't pick all available types
- Was hardcoded list of 9 types (checkpoints, loras, vae, etc.)
- Now fetched dynamically from /api/comfy/types, which calls the new
`worker.py types` command — lists actual subdirectories of
gpu/comfy/models.
- Falls back to hardcoded list if worker is offline or older version.
## Files changed
- model-worker/worker.py:
* Added json import
* Added command_list_json(model_type) — JSON variant of command_list
* Added command_queue_json() — JSON variant of command_queue
* Added `types` command (outputs JSON array of subdir names)
* `list` command now accepts --json flag
* `queue` command now accepts --json flag
* print_usage() updated
- dashboard/src/app/api/services/[role]/stream/route.ts — new SSE endpoint
- dashboard/src/app/api/comfy/types/route.ts — new (proxy to worker.py types)
- dashboard/src/app/api/debug/route.ts — new (diagnostic endpoint)
- dashboard/src/lib/docker.ts:
* listComfyModels uses --json flag
* getComfyQueue uses --json flag
* Added getComfyTypes() — calls worker.py types
* Better error handling for type-not-found case
- dashboard/src/app/page.tsx:
* Renamed 'Llama Dashboard' → 'GPU Node Dashboard'
* LiveLogs type changed from string[] to {stream, line, ts}[]
* startLogsStream uses EventSource instead of fetch+readablestream
* Added comfyTypes state, refreshComfyTypes callback
* ComfyTab receives dynamic types list (with fallback)
- dashboard/src/app/layout.tsx: title renamed
|
||
|
|
3dc57f5eaf |
feat(dashboard): v2 — SSE status, model upload, comfy management, system controls
## Fixes
- **Dockerfile build failure on legacy builder**: removed `COPY yarn.lock*`
wildcard (legacy builder fails when no file matches). Now uses explicit
`COPY package.json package-lock.json ./`.
- Added `dashboard/.dockerignore` to exclude node_modules/.next from build
context (faster builds, smaller context).
## New features
### Real-time status via SSE (replaces fetch polling)
- New `/api/status/stream` endpoint emits `status` event every 4s with
full containers + llama health payload.
- Frontend opens single `EventSource` connection instead of polling.
Auto-reconnects on disconnect.
- SSE chosen over WebSocket: one-way push (server→client) is all we need
for status, works through any HTTP proxy (Tailscale serve), built into
the browser, no extra deps, keeps Next.js standalone output.
### .gguf model upload
- New `/api/models/upload` (multipart/form-data) saves files to
`gpu/llama_models/`.
- Drag-and-drop dropzone + click-to-upload in the Models tab.
- Live progress bar via XMLHttpRequest upload progress event.
- New `DELETE /api/models?name=...` removes a model.
- Filename sanitization: only .gguf, no path traversal.
### ComfyUI models management (mirrors `gpuctl comfy models ...`)
- New API routes:
- `GET /api/comfy/models?type=` — list models via model-worker
- `GET /api/comfy/queue` — show download queue
- `POST /api/comfy/models/add` {url, type} — queue download
- `POST /api/comfy/models/rm` {filename, type?} — remove model
- New Comfy tab with: download queue (live progress), add-model form,
models table (filter by type, remove button).
- All proxied through `docker exec model-worker python3 /app/worker.py ...`.
### ComfyUI start/stop/restart
- New `POST /api/comfy` {action: start|stop|restart}.
- 4 new quick-action cards on the dashboard home.
### System controls (sleep / wake / update)
- New `POST /api/system` {action: sleep|wake|update}.
- Header buttons (Sleep / Wake / Update) with confirmation dialogs.
- `update` runs `sh build.sh` then `docker compose up -d --force-recreate`.
### Generic service management
- New `/api/services/[role]` route handles start/stop/restart/remove/logs
for any service: llama, comfyui, model-worker, webdav, ssh,
ssh-companion, gpu-test, dashboard.
- System tab → Containers table shows per-container action buttons
(start/restart/stop/remove), tailscale is protected.
### Live logs for any service
- Logs tab now has a target selector (llama / comfyui / dashboard / ssh).
- Uses `/api/services/<role>` streaming endpoint.
## Shell script updates (`gpuctl` integration)
- `ssh/scripts/status.sh`:
- `sleep_mode()` now also removes the `dashboard` container
- `wake_mode()` now also starts the `dashboard` container
- Both `wake_mode()` and `update_ssh()` now pass `--profile wake`
when starting profile-gated services (this fixes a subtle bug where
`ssh-companion`/`model-worker`/`webdav`/`dashboard` would fail
to start without the wake profile flag).
- `ssh/gpuctl` usage text updated to list `dashboard`.
## WSL restart script
- New `RESTART_WSL.bat` next to `START_GPU_NODE.bat`:
1. Checks if WSL is running, starts it if not
2. `wsl --shutdown` + 3s wait
3. Wakes WSL back up
4. `docker compose up -d` to start GPU node services
5. Shows running containers
## ssh-only-tailscale-after-reboot investigation
Most likely cause: empty `HOST_PROJECT_PATH` in `.env`.
- `ssh/entrypoint.sh` exits 1 if `HOST_PROJECT_PATH` is unset
- With `restart: always`, Docker daemon keeps trying to restart it on
every boot, but it crashes immediately each time
- `tailscale` doesn't need this env var, so it starts cleanly
Fix: added a hard fail at the top of `compose.yaml`:
```yaml
# ${HOST_PROJECT_PATH:?ERROR: HOST_PROJECT_PATH must be set in .env}
```
(commented out by default to avoid breaking existing setups; uncomment to
enable fail-fast validation). Also updated `.env.example` with a clear
warning about this gotcha.
Alternative cause (less likely): if `gpuctl sleep` was called before the
reboot, the `ssh` container may have been removed entirely. After reboot,
Docker has no container to restart, so only `tailscale` (which `sleep_mode`
preserves) comes back. Fix: run `docker compose up -d` after reboot to
re-create the ssh container, or just call `gpuctl wake` from the dashboard.
## Files added/changed
- `dashboard/Dockerfile` — fixed COPY commands
- `dashboard/.dockerignore` — new
- `dashboard/src/app/page.tsx` — major rewrite (comfy, sleep/wake, upload, SSE)
- `dashboard/src/app/api/status/stream/route.ts` — new SSE endpoint
- `dashboard/src/app/api/models/route.ts` — added DELETE
- `dashboard/src/app/api/models/upload/route.ts` — new
- `dashboard/src/app/api/comfy/route.ts` — new
- `dashboard/src/app/api/comfy/models/route.ts` — new
- `dashboard/src/app/api/comfy/queue/route.ts` — new
- `dashboard/src/app/api/comfy/models/add/route.ts` — new
- `dashboard/src/app/api/comfy/models/rm/route.ts` — new
- `dashboard/src/app/api/system/route.ts` — new
- `dashboard/src/app/api/services/[role]/route.ts` — new
- `dashboard/src/lib/docker.ts` — added start/stop/restart/remove services,
comfy models proxy, sleep/wake/update, model upload/delete
- `ssh/scripts/status.sh` — sleep_mode + wake_mode + update_ssh updated
- `ssh/gpuctl` — usage text updated
- `compose.yaml` — added HOST_PROJECT_PATH validation comment
- `.env.example` — added HOST_PROJECT_PATH warning, LLAMA_EXTRA_ARGS
- `RESTART_WSL.bat` — new
|