feat: add llama dashboard for managing launch config via web UI
Adds a small Next.js dashboard as a new Docker service () that replaces the need to manually edit and call over SSH every time you want to tweak llama launch parameters. Features: - Live status panel for all GPU-node containers (auto-refresh) - Models list with file sizes, click-to-select active model - Structured launch config form: * Model, ctx-size, parallel, batch-size, n-gpu-layers, threads * Context overflow (none / shift / evict) * Speculative decoding (spec-type, draft model, spec-draft-n-max) * Free-form extra args textarea for anything else - Named presets (save / load / delete) - Start / Restart / Stop / Remove llama actions - Live streaming logs viewer (docker logs -f) - GPU status (nvidia-smi via docker exec on llama) - Auto-writes LLAMA_MODEL and LLAMA_EXTRA_ARGS back to .env so the existing workflow keeps working, and persists full structured config to gpu/dashboard/config.json for reload on next visit Integration: - New service in compose.yaml (no profile, runs always) - Mounts /var/run/docker.sock + HOST_PROJECT_PATH - Tailscale serve exposes port 8090 -> dashboard:3000 - build.sh extended to build the dashboard image Tech: Next.js 16 standalone, React 19, TypeScript 5, Tailwind 4, shadcn-style components, Radix UI primitives.
This commit is contained in:
76
dashboard/src/app/api/logs/route.ts
Normal file
76
dashboard/src/app/api/logs/route.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { NextRequest } from "next/server";
|
||||
import { getLlamaContainerName } from "@/lib/docker";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
export const runtime = "nodejs";
|
||||
export const maxDuration = 300;
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const name = await getLlamaContainerName();
|
||||
if (!name) {
|
||||
return new Response("[llama container not found]", {
|
||||
headers: {
|
||||
"Content-Type": "text/plain; charset=utf-8",
|
||||
"Cache-Control": "no-cache, no-transform",
|
||||
"X-Accel-Buffering": "no",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const tail = Number(req.nextUrl.searchParams.get("tail") || 500);
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
const stream = new ReadableStream<Uint8Array>({
|
||||
async start(controller) {
|
||||
controller.enqueue(
|
||||
encoder.encode(
|
||||
`=== Streaming logs for ${name} (tail=${tail}) ===\n`
|
||||
)
|
||||
);
|
||||
|
||||
const { spawn } = await import("node:child_process");
|
||||
const child = spawn("docker", ["logs", "-f", "--tail", String(tail), "--timestamps", name]);
|
||||
|
||||
const enqueue = (chunk: Buffer | string) => {
|
||||
try {
|
||||
controller.enqueue(encoder.encode(chunk.toString()));
|
||||
} catch {
|
||||
/* stream closed */
|
||||
}
|
||||
};
|
||||
|
||||
child.stdout.on("data", enqueue);
|
||||
child.stderr.on("data", enqueue);
|
||||
|
||||
child.on("error", (err) => {
|
||||
controller.enqueue(encoder.encode(`[stream error: ${err.message}]\n`));
|
||||
controller.close();
|
||||
});
|
||||
child.on("exit", () => {
|
||||
try {
|
||||
controller.close();
|
||||
} catch {
|
||||
/* already closed */
|
||||
}
|
||||
});
|
||||
|
||||
// Abort signal from client disconnect
|
||||
req.signal.addEventListener("abort", () => {
|
||||
try {
|
||||
child.kill("SIGTERM");
|
||||
} catch {
|
||||
/* noop */
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return new Response(stream, {
|
||||
headers: {
|
||||
"Content-Type": "text/plain; charset=utf-8",
|
||||
"Cache-Control": "no-cache, no-transform",
|
||||
"X-Accel-Buffering": "no",
|
||||
Connection: "keep-alive",
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user