Once you install a few local AI tools such as Ollama, ComfyUI and AivisSpeech, it gets hard to tell what is running and what is eating your VRAM. On an 8GB card, Ollama often keeps a model loaded in the background and ComfyUI then crashes with an out-of-memory error.
So I had Claude Code build me a dashboard that shows every local AI service and the VRAM usage on one screen, with start and stop buttons.
Short answer: install Node.js, put five files in one folder and double-click start.cmd. There is no installer and no npm package to add. The only thing you edit for your own PC is a few lines in services.mjs.

What the dashboard does
| Feature | Details |
|---|---|
| Running services on top | Cards for “running” and “needs attention” services appear at the top. Stopped services only appear in the table below |
| Table of everything | Status, name, port, description, info and buttons, one row per service. Refreshes every 5 seconds |
| VRAM | The top bar shows the GPU name and VRAM usage (NVIDIA only). For Ollama it also shows the loaded model and how much VRAM it uses |
| Start / stop | Start and Stop buttons. Stop asks for confirmation and only kills a process after checking that it really is that service |
| Open | Running services get “Open” / “API” buttons, e.g. to open the ComfyUI page in a new tab |
| Logs | Output of anything started from the dashboard can be read on the page |
| Port conflicts | If another program is using the same port, it shows “used by another process” and refuses to start or stop it |
Out of the box it lists Ollama, AivisSpeech Engine (a Japanese text-to-speech engine) and ComfyUI, but a few lines in services.mjs let you add anything: your own apps, Stable Diffusion WebUI, an English TTS server, and so on.
Note: the UI labels and code comments are in Japanese because I built it for myself. The buttons are simple : 起動 (Start), 停止 (Stop), 開く (Open) and ログ (Log), and the group names and descriptions live in services.mjs, so you can change them into English there.
Requirements
- Windows 10/11 (the way it looks up processes and ports is Windows-only)
- Node.js 20.11 or later (it uses
import.meta.dirname; I tested with v26.13.1). Nothing to install with npm - An NVIDIA GPU if you want the VRAM bar (it uses
nvidia-smi; without it the bar is simply hidden and everything else works)
If you don’t have Node.js yet, use the installer from the official site or run this in PowerShell:
winget install --id OpenJS.NodeJS.LTS -e
Reopen PowerShell afterwards and check that node -v prints a version.
How to use it
1. Put the files in a folder
Download the ZIP and extract it anywhere (for example D:\tools\local-ai-dashboard). It contains the same five files as the full code at the end of this post, so you can also create them by copy-paste.
local-ai-dashboard.zip (about 15KB)
To make sure the ZIP isn’t corrupted, compare its SHA256 in PowerShell with the value below.
Get-FileHash .\local-ai-dashboard.zip -Algorithm SHA256
384E6CD77032DDB71FC2762454F726282D592937FFAE0DC4A95DA5D5E974D7E8
If you create the files by copy-paste, save the .mjs and .html files as UTF-8 (Notepad on Windows 11 does this by default). The .cmd files are ASCII only, so encoding doesn’t matter for them.
2. Point services.mjs at your install folders
Open services.mjs in a text editor and adjust lines 24-26. If you installed Ollama and AivisSpeech normally, lines 24 and 25 can stay as they are. For ComfyUI, enter the folder where you extracted the portable version. Write every \ in a path as \\.
import path from 'node:path'; // ---- 自分の環境に合わせて書き換える場所 ---- const LOCAL = process.env.LOCALAPPDATA; // C:\Users\(ユーザー名)\AppData\Local const OLLAMA_EXE = path.join(LOCAL, 'Programs', 'Ollama', 'ollama.exe'); // Ollama を普通にインストールした場所 const AIVIS_DIR = path.join(LOCAL, 'Programs', 'AivisSpeech', 'AivisSpeech-Engine'); // AivisSpeech のエンジン const COMFY = 'C:\\ComfyUI_windows_portable'; // ComfyUI(ポータブル版)を展開した場所
If a path is wrong, pressing Start shows “起動するファイルが見つかりません” (file to start not found) together with the path, so you’ll notice right away.
3. Double-click start.cmd
Double-clicking start.cmd starts the dashboard server in the background and opens http://127.0.0.1:3999/ in your browser. No console window stays open. If the server is already running it just opens the page. Bookmark it, and from then on just open the bookmark (after a reboot, run start.cmd again).

To stop the dashboard itself, run stop.cmd. Only the dashboard stops; Ollama, ComfyUI and the rest keep running.
4. Start and stop services
Press Start in the table and it shows “waiting for a response”. When the service is up, the row turns green and a card appears at the top. On my PC Ollama took about 2 seconds and ComfyUI 20-60 seconds. ComfyUI is started with the browser auto-launch disabled, so press Open when you want to use it.
Stop asks for confirmation and then ends the process. Ollama and AivisSpeech are often shared by several apps, so their confirmation adds a note that apps using them will lose their voice or chat.
Reading the screen
| Status | Meaning |
|---|---|
| Running (green) | The port is open and the service answers |
| Stopped (gray) | Nothing is using the port |
| No response (orange) | The process exists but doesn’t answer the health check (still starting, or hung) |
| Used by another process (orange) | A different program is listening on the service’s port |
| Starting / stopping (blue, blinking) | The dashboard is in the middle of starting or stopping it |
The Info column shows the loaded model and its VRAM for Ollama, and the version for the others. “詳細▸” (Details) on the right shows how the service is started and its command line, and the Log button opens the log.

Logs are only available for services started from the dashboard. When another program holds the port, it looks like this:

Both buttons are disabled so it never kills an unrelated program. It is also handy for spotting things like “Ollama won’t start because another app’s bundled Ollama is holding the port”. The “other listening ports” section at the bottom lists every listening port and process that isn’t defined in services.mjs.
What to change: quick reference
Line numbers refer to the code in this post.
| What you want to change | File and place | How |
|---|---|---|
| Install paths of Ollama, AivisSpeech, ComfyUI | services.mjs lines 24-26 | Edit the paths (\ becomes \\) |
| How long Ollama keeps a model loaded | services.mjs line 46 | Change 30m in OLLAMA_KEEP_ALIVE: '30m' to 5m (the default) or 0 (unload right after use). Shorter is better if VRAM is tight |
| Run AivisSpeech on the GPU | services.mjs line 56 | Add the option --use_gpu (quoted like the other arguments) at the end of the argument list. Without it, it runs on the CPU and uses no VRAM |
| Add a service | services.mjs lines 70-80 | Remove the leading // from the sample and edit it. Each field is explained in lines 1-19 |
| Table groups | services.mjs lines 31-36 | Add entries like { id: 'mine', name: 'My apps' } |
| Names, descriptions, buttons | services.mjs name, desc, open of each service |
Change them into English, or write your own notes |
| Dashboard port (3999) | Environment variable SERVICE_STATUS_PORT |
Set it as a Windows environment variable; server.mjs, start.cmd and stop.cmd all follow it |
| Refresh interval | index.html line 121 | busy ? 2000 : 5000 (2 s while busy, 5 s otherwise) |
| Max wait for a service to start | server.mjs lines 175 and 185 | 6 * 60000 (6 minutes). Increase it for heavy models |
| Colors | index.html lines 8-16 | Light and dark colors (follows the Windows theme) |
For example, to add the chat-web.ps1 (port 8770) from my voice and picture AI character chat, you can use the sample almost as is. Write PowerShell scripts as ps1(...) and executables as exe(...). In expect, put a regular expression for text that always appears in that process’s command line (the script or folder name). If it doesn’t match, your own app will show up as “used by another process”.
How it works
Each time the page asks, the server (server.mjs) uses PowerShell to get the listening ports (Get-NetTCPConnection) and the command line of every process (Get-CimInstance Win32_Process), and works out who owns each port in services.mjs. If the command line matches expect, it’s the real service; it then requests the health path over HTTP and marks the service as running if it answers. VRAM comes from Ollama’s /api/ps and nvidia-smi (ComfyUI’s /system_stats free memory ignores other processes, so its numbers didn’t match and I don’t use it).
Start runs whatever is in start without a window and polls health every 2 seconds. Stop checks that the command line matches expect and then runs taskkill /T /F to end the process together with its children (Ollama spawns a separate child process).
Because this server can kill processes, it only listens on 127.0.0.1, rejects requests whose Host header isn’t 127.0.0.1:3999 or localhost:3999, rejects start/stop requests without a custom header, and rejects requests sent from other sites. That stops a malicious web page open in your browser from silently sending “stop” in the background.
Limitations
- Windows only. On macOS or Linux you would need to rewrite the process and port lookup
- The VRAM bar is NVIDIA only. On AMD or Intel GPUs the bar is hidden (everything else works)
- Starting Ollama runs only
ollama serve, so no tray icon appears. If you normally start Ollama from the tray, use the dashboard to watch and stop it - Starting AivisSpeech runs only the engine (
run.exe). While the AivisSpeech app is open it owns the engine, so stopping it from the dashboard silences the app - Logs are only kept for services started from the dashboard
- It doesn’t start automatically at boot. If you want that, put a shortcut to
start.cmdin your Startup folder (Win+R, thenshell:startup)
How I built it with Claude Code
It started with “find the servers I can run on this PC and list their ports and how to start them”. Then I asked for “a web page that checks their status”, “start and stop buttons” and “running ones picked out at the top”, and by the next afternoon it looked like it does now. On my own PC it lists 18 services and I use it every day. For this public version I removed my personal paths, switched to the standard install locations, ran it end to end from scratch and fixed everything I tripped over.
Full code
Put the five files in the same folder. Feel free to use, modify and redistribute this code (no need to ask, no warranty).
services.mjs (services to watch)
// ダッシュボードに出すサービスの一覧。ここを書き換えれば、自分の環境に合わせられる。
//
// 各項目の意味:
// id : 半角英数字とハイフンの名前(ログのファイル名にも使う)
// group : 下の groups の id。表で同じ見出しの下にまとまる
// port : そのサービスが待ち受けるポート番号
// name : 画面に出す名前 / desc: 説明
// open : 起動中に出す「開く」ボタン(label と url)
// health : 生きているか確かめるために GET するパス
// expect : そのポートを使っているプロセスのコマンドラインがこれに合うときだけ「本物」とみなす。
// 合わないとき(別のアプリがポートを使っている)は「別プロセスが使用中」と出し、停止もしない
// parent : 停止するとき、親プロセスがこれに合う間は親までさかのぼって止める(親が子を再起動するアプリ向け)
// kind : 'ollama' = 読み込み中のモデルを表示 / 'comfy' = ComfyUIの版数を表示 / 'version' = バージョンを表示
// shared : true にすると、停止の確認に「複数のアプリで共用」と出る
// stop : 停止ボタンで実行するもの(書かなければ、そのポートを使っているプロセスを止める)
// start : 起動ボタンで実行するもの。steps を上から順に実行する
// exe(実行ファイル, 引数の配列, 作業フォルダ, 環境変数) / ps1(PowerShellスクリプト, 引数の配列)
// launchers: 詳細欄に出す「ふだんの起動方法」のメモ(パスならコピーボタンが付く)
import path from 'node:path';
// ---- 自分の環境に合わせて書き換える場所 ----
const LOCAL = process.env.LOCALAPPDATA; // C:\Users\(ユーザー名)\AppData\Local
const OLLAMA_EXE = path.join(LOCAL, 'Programs', 'Ollama', 'ollama.exe'); // Ollama を普通にインストールした場所
const AIVIS_DIR = path.join(LOCAL, 'Programs', 'AivisSpeech', 'AivisSpeech-Engine'); // AivisSpeech のエンジン
const COMFY = 'C:\\ComfyUI_windows_portable'; // ComfyUI(ポータブル版)を展開した場所
const exe = (file, args = [], cwd = path.dirname(file), env = {}) => ({ type: 'exe', file, args, cwd, env });
const ps1 = (file, args = [], wait = false) => ({ type: 'ps1', file, args, wait });
export const groups = [
{ id: 'llm', name: '会話AI' },
{ id: 'voice', name: '音声合成' },
{ id: 'image', name: '画像生成' },
// { id: 'mine', name: '自作アプリ' },
];
export const services = [
{
id: 'ollama', group: 'llm', port: 11434, kind: 'ollama',
name: 'Ollama',
desc: 'ローカルで会話AIを動かすエンジン。モデルを読み込むとVRAMを使う。',
open: [{ label: 'API', url: 'http://127.0.0.1:11434/api/version' }],
health: { path: '/api/version' },
expect: /ollama/i, parent: /ollama app\.exe/i, shared: true,
start: { steps: [exe(OLLAMA_EXE, ['serve'], undefined, { OLLAMA_KEEP_ALIVE: '30m' })] },
launchers: [OLLAMA_EXE, 'スタートメニューの Ollama(タスクトレイに常駐する)'],
},
{
id: 'aivis', group: 'voice', port: 10101, kind: 'version',
name: 'AivisSpeech Engine',
desc: '日本語の読み上げエンジン。アプリ本体を開かずにエンジンだけ起動する。',
open: [{ label: 'API', url: 'http://127.0.0.1:10101/docs' }],
health: { path: '/version' },
expect: /AivisSpeech/i, shared: true,
start: { steps: [exe(path.join(AIVIS_DIR, 'run.exe'), ['--host', '127.0.0.1', '--port', '10101'])] },
launchers: [path.join(AIVIS_DIR, 'run.exe'), 'スタートメニューの AivisSpeech(アプリ本体と一緒にエンジンも立つ)'],
},
{
id: 'comfyui', group: 'image', port: 8188, kind: 'comfy',
name: 'ComfyUI',
desc: '画像・動画生成。ブラウザが勝手に開かないようにして起動する。',
open: [{ label: '開く', url: 'http://127.0.0.1:8188' }],
health: { path: '/system_stats' },
expect: /ComfyUI/i,
start: { steps: [exe(`${COMFY}\\python_embeded\\python.exe`, ['-s', 'ComfyUI\\main.py', '--windows-standalone-build', '--disable-auto-launch'], COMFY)] },
launchers: [`${COMFY}\\run_nvidia_gpu.bat`],
},
// ---- 自分のアプリを足すときの見本(先頭の // を消して書き換える) ----
// {
// id: 'my-app', group: 'mine', port: 8770,
// name: '自作チャット',
// desc: 'PowerShell で動かしている自作のチャット画面。',
// open: [{ label: '開く', url: 'http://127.0.0.1:8770/' }],
// health: { path: '/' },
// expect: /chat-web\.ps1/i,
// start: { steps: [ps1('D:\\tools\\chat\\chat-web.ps1')] },
// launchers: ['D:\\tools\\chat\\chat-web.ps1'],
// },
];
server.mjs (status check, start and stop)
// ローカルAIの状態確認・起動・停止を行うダッシュボード。http://127.0.0.1:3999/
// 見るサービスは services.mjs に書く。このファイルは書き換えなくても動く。
import http from 'node:http';
import fs from 'node:fs';
import path from 'node:path';
import { spawn, execFile } from 'node:child_process';
import { groups, services } from './services.mjs';
const PORT = Number(process.env.SERVICE_STATUS_PORT || 3999);
const ROOT = import.meta.dirname;
const LOGS = path.join(ROOT, 'logs');
fs.mkdirSync(LOGS, { recursive: true });
const byId = new Map(services.map(s => [s.id, s]));
const jobs = new Map(); // id -> { action, state: 'running'|'done'|'error', message, at }
// ---- プロセス・ポートのスナップショット ----
const PS_SNAPSHOT = `
[Console]::OutputEncoding = [Text.Encoding]::UTF8
$l = @(Get-NetTCPConnection -State Listen -ErrorAction SilentlyContinue | Select-Object LocalAddress, LocalPort, OwningProcess)
$p = @(Get-CimInstance Win32_Process | Select-Object ProcessId, ParentProcessId, Name, CommandLine, ExecutablePath)
@{ listen = $l; procs = $p } | ConvertTo-Json -Compress -Depth 3
`;
const encoded = Buffer.from(PS_SNAPSHOT, 'utf16le').toString('base64');
let snapCache = null, snapAt = 0, snapPending = null;
function runFile(file, args, opts = {}) {
return new Promise(resolve => {
execFile(file, args, { windowsHide: true, maxBuffer: 64 * 1024 * 1024, timeout: 30000, ...opts }, (err, stdout, stderr) =>
resolve({ err, stdout: String(stdout || ''), stderr: String(stderr || '') }));
});
}
async function snapshot(force = false) {
if (!force && snapCache && Date.now() - snapAt < 1500) return snapCache;
if (snapPending) return snapPending;
snapPending = (async () => {
const r = await runFile('powershell.exe', ['-NoProfile', '-NonInteractive', '-EncodedCommand', encoded]);
const data = JSON.parse(r.stdout.trim() || '{"listen":[],"procs":[]}');
const procs = new Map(data.procs.map(p => [p.ProcessId, p]));
snapCache = { listen: data.listen, procs }; snapAt = Date.now();
return snapCache;
})().finally(() => { snapPending = null; });
return snapPending;
}
async function gpu() {
const r = await runFile('nvidia-smi', ['--query-gpu=name,memory.used,memory.total,utilization.gpu', '--format=csv,noheader,nounits'], { timeout: 5000 });
if (r.err) return null;
const [name, used, total, util] = r.stdout.trim().split('\n')[0].split(',').map(x => x.trim());
return { name, used: Number(used), total: Number(total), util: Number(util) };
}
function httpGet(port, p, timeout = 4000) {
return new Promise(resolve => {
const t0 = Date.now();
const req = http.get({ host: '127.0.0.1', port, path: p, timeout }, res => {
let body = '';
res.setEncoding('utf8');
res.on('data', c => { if (body.length < 65536) body += c; });
res.on('end', () => {
let json = null; try { json = JSON.parse(body); } catch {}
resolve({ ok: res.statusCode < 500, status: res.statusCode, json, body: json ? null : body.slice(0, 200), raw: body, ms: Date.now() - t0 });
});
});
req.on('timeout', () => { req.destroy(); resolve({ ok: false, error: '応答待ちタイムアウト' }); });
req.on('error', e => resolve({ ok: false, error: e.code || e.message }));
});
}
const cmdOf = p => (p && (p.CommandLine || p.ExecutablePath || p.Name)) || '';
const listenersOf = (snap, port) => snap.listen.filter(l => l.LocalPort === port);
const isListening = (snap, s) => listenersOf(snap, s.port).length > 0;
const hasMarker = (s, health) => !!(s.marker && health?.raw?.includes(s.marker));
async function serviceStatus(s, snap) {
const ls = listenersOf(snap, s.port);
const pids = [...new Set(ls.map(l => l.OwningProcess))];
const procs = pids.map(pid => snap.procs.get(pid)).filter(Boolean);
let match = procs.some(p => s.expect.test(cmdOf(p)));
let health = null, extra = null, state;
if (ls.length) {
health = await httpGet(s.port, s.health?.path || '/');
match ||= hasMarker(s, health);
if (match && health.ok) {
if (s.kind === 'ollama') {
const r = await httpGet(s.port, '/api/ps', 3000);
extra = { models: (r.json?.models || []).map(m => ({ name: m.name, vramGB: +(m.size_vram / 1024 ** 3).toFixed(1) })) };
} else if (s.kind === 'comfy') {
// ComfyUI が返す VRAM の空きは Windows ではGPU全体の実際とずれることがあるので、版数だけ出す(VRAMは上のGPU表示で見る)
extra = { version: health.json?.system?.comfyui_version || '?' };
} else if (s.kind === 'version') extra = { version: health.json ?? health.body };
}
state = !match ? 'foreign' : health.ok ? 'running' : 'unhealthy';
} else state = 'stopped';
const job = jobs.get(s.id);
if (job?.state === 'running') state = job.action === 'start' ? 'starting' : 'stopping';
return {
id: s.id, state, extra,
process: procs.map(p => ({ pid: p.ProcessId, name: p.Name, cmd: cmdOf(p) })),
health: health && { ok: health.ok, status: health.status, error: health.error, ms: health.ms },
job: job && { action: job.action, state: job.state, message: job.message, at: job.at },
};
}
function publicDef(s) {
return {
id: s.id, group: s.group, name: s.name, port: s.port, desc: s.desc, open: s.open || [],
deps: s.deps || [], conflicts: s.conflicts || [], launchers: s.launchers || [],
shared: !!s.shared, canStart: !!s.start, stopByScript: !!s.stop,
};
}
async function fullStatus() {
const [snap, g] = await Promise.all([snapshot(), gpu()]);
const list = await Promise.all(services.map(s => serviceStatus(s, snap)));
const known = new Set([...services.map(s => s.port), PORT]);
const seen = new Set();
const others = snap.listen
.filter(l => !known.has(l.LocalPort) && !seen.has(l.LocalPort) && seen.add(l.LocalPort))
.sort((a, b) => a.LocalPort - b.LocalPort)
.map(l => { const p = snap.procs.get(l.OwningProcess); return { port: l.LocalPort, addr: l.LocalAddress, pid: l.OwningProcess, name: p?.Name || '', cmd: p?.CommandLine || '' }; });
return { time: new Date().toISOString(), gpu: g, groups, services: services.map(publicDef), status: list, others };
}
// ---- 起動・停止 ----
const logPath = id => path.join(LOGS, `${id}.log`);
const sleep = ms => new Promise(r => setTimeout(r, ms));
function spawnStep(s, step) {
const isPs1 = step.type === 'ps1';
const exe = isPs1 ? 'powershell.exe' : step.file;
const args = isPs1 ? ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', step.file, ...(step.args || [])] : (step.args || []);
const cwd = step.cwd || path.dirname(step.file);
fs.appendFileSync(logPath(s.id), `\n=== ${new Date().toLocaleString('ja-JP')} 実行: ${exe} ${args.join(' ')}\n`);
const fd = fs.openSync(logPath(s.id), 'a');
const child = spawn(exe, args, {
cwd, env: { ...process.env, ...(step.env || {}) }, detached: true,
// GUI アプリ(VOICEVOX)はウィンドウを隠すと操作できなくなるので表示する
windowsHide: !/VOICEVOX\.exe$/i.test(exe), stdio: ['ignore', fd, fd],
});
fs.closeSync(fd);
const exited = new Promise(resolve => {
child.on('exit', code => resolve(code));
child.on('error', e => { fs.appendFileSync(logPath(s.id), `起動失敗: ${e.message}\n`); resolve(-1); });
});
child.unref();
return exited;
}
async function waitFor(fn, ms, every = 1500) {
const end = Date.now() + ms;
while (Date.now() < end) { if (await fn()) return true; await sleep(every); }
return false;
}
const setJob = (id, action, state, message) => jobs.set(id, { action, state, message, at: Date.now() });
async function startService(s) {
const snap = await snapshot(true);
if (isListening(snap, s)) throw new Error(`ポート ${s.port} はすでに使われています`);
for (const c of s.conflicts || []) {
const cs = byId.get(c);
if (cs && isListening(snap, cs)) throw new Error(`「${cs.name}」(${cs.port}) が起動中のため同時に起動できません`);
}
const missing = s.start.steps.find(step => !fs.existsSync(step.file));
if (missing) throw new Error(`起動するファイルが見つかりません: ${missing.file}\nservices.mjs の場所を自分の環境に合わせて直してください`);
setJob(s.id, 'start', 'running', '起動処理を実行中…');
(async () => {
try {
let lastExit = null;
for (const [i, step] of s.start.steps.entries()) {
if (s.start.steps.length > 1) setJob(s.id, 'start', 'running', `手順 ${i + 1}/${s.start.steps.length} を実行中…`);
const exited = spawnStep(s, step);
if (step.wait) {
const code = await Promise.race([exited, sleep(6 * 60000).then(() => 'timeout')]);
if (code !== 0) throw new Error(`前処理が失敗しました (終了コード ${code})。ログを確認してください`);
} else lastExit = exited;
}
setJob(s.id, 'start', 'running', '応答を待っています…');
let failedCode = null;
lastExit?.then(code => { if (code !== 0 && code !== null) failedCode = code; });
const ok = await waitFor(async () => {
if (failedCode !== null && !isListening(await snapshot(true), s)) throw new Error(`起動プロセスが終了しました (終了コード ${failedCode})。ログを確認してください`);
return (await httpGet(s.port, s.health?.path || '/')).ok;
}, 6 * 60000, 2000);
if (!ok) throw new Error('6分待っても応答がありません。ログを確認してください');
setJob(s.id, 'start', 'done', '起動しました');
} catch (e) { setJob(s.id, 'start', 'error', e.message); }
})();
}
async function stopService(s) {
const snap = await snapshot(true);
const ls = listenersOf(snap, s.port);
if (!ls.length && !s.stop) throw new Error('起動していません');
const markerOk = ls.length && hasMarker(s, await httpGet(s.port, s.health?.path || '/'));
if (ls.length && !markerOk && !ls.some(l => s.expect.test(cmdOf(snap.procs.get(l.OwningProcess))))) throw new Error(`ポート ${s.port} は別のプロセスが使っているため停止しません`);
setJob(s.id, 'stop', 'running', 'プロセスを終了しています…');
(async () => {
try {
if (s.stop) {
const code = await spawnStep(s, s.stop);
if (code !== 0) throw new Error(`停止スクリプトが失敗しました (終了コード ${code})`);
} else {
const targets = new Set();
for (const l of ls) {
let p = snap.procs.get(l.OwningProcess);
if (!p || !(markerOk || s.expect.test(cmdOf(p)))) continue;
// next dev などは親プロセスごと止めないと再起動されるので、定義に一致する親までさかのぼる
for (let parent = snap.procs.get(p.ParentProcessId); s.parent && parent && s.parent.test(cmdOf(parent)); parent = snap.procs.get(parent.ParentProcessId)) p = parent;
targets.add(p.ProcessId);
}
for (const pid of targets) {
fs.appendFileSync(logPath(s.id), `\n=== ${new Date().toLocaleString('ja-JP')} 停止: PID ${pid} ${cmdOf(snap.procs.get(pid))}\n`);
await runFile('taskkill.exe', ['/PID', String(pid), '/T', '/F']);
}
}
const freed = await waitFor(async () => !isListening(await snapshot(true), s), 30000, 1000);
setJob(s.id, 'stop', freed ? 'done' : 'error', freed ? '停止しました' : '停止処理後もポートが使われています');
} catch (e) { setJob(s.id, 'stop', 'error', e.message); }
})();
}
// ---- HTTP ----
// 状態確認のアクセス記録(Ollama の [GIN] 行、AivisSpeech の INFO 行)
const POLL_LINE = /\[GIN\].*"\/api\/(version|ps)"|"GET \/(version|system_stats) HTTP\/1\.1" 200/;
const ALLOWED_HOSTS = [`127.0.0.1:${PORT}`, `localhost:${PORT}`];
function send(res, code, body, type = 'application/json; charset=utf-8') {
res.writeHead(code, { 'Content-Type': type, 'Cache-Control': 'no-store' });
res.end(typeof body === 'string' ? body : JSON.stringify(body));
}
http.createServer(async (req, res) => {
try {
if (!ALLOWED_HOSTS.includes(req.headers.host)) return send(res, 403, { error: 'Host not allowed' });
const url = new URL(req.url, `http://${req.headers.host}`);
if (req.method === 'GET' && url.pathname === '/') return send(res, 200, fs.readFileSync(path.join(ROOT, 'index.html'), 'utf8'), 'text/html; charset=utf-8');
if (req.method === 'GET' && url.pathname === '/api/ping') return send(res, 200, { ok: true, app: 'service-status' });
if (req.method === 'GET' && url.pathname === '/api/status') return send(res, 200, await fullStatus());
const m = url.pathname.match(/^\/api\/services\/([\w-]+)\/(start|stop|log)$/);
if (m && byId.has(m[1])) {
const s = byId.get(m[1]);
if (m[2] === 'log' && req.method === 'GET') {
const p = logPath(s.id);
// このダッシュボード自身の状態確認(5秒ごと)の記録は読みにくくなるだけなので省く
const text = fs.existsSync(p) ? fs.readFileSync(p, 'utf8').slice(-400000).split('\n').filter(l => !POLL_LINE.test(l)).join('\n').slice(-16000) : '(まだログはありません)';
return send(res, 200, { path: p, text });
}
if (req.method === 'POST') {
// 別サイトのページからの操作を防ぐ(カスタムヘッダー必須 + Origin 確認)
const origin = req.headers.origin;
if (req.headers['x-dashboard'] !== '1' || (origin && !ALLOWED_HOSTS.some(h => origin === `http://${h}`))) return send(res, 403, { error: 'Forbidden' });
if (jobs.get(s.id)?.state === 'running') return send(res, 409, { error: '処理中です' });
if (m[2] === 'start') {
if (!s.start) return send(res, 400, { error: 'このサービスは単独では起動できません' });
await startService(s);
} else await stopService(s);
return send(res, 202, { ok: true });
}
}
send(res, 404, { error: 'Not found' });
} catch (e) { send(res, 400, { error: e.message }); }
}).listen(PORT, '127.0.0.1', () => console.log(`サービス状況: http://127.0.0.1:${PORT}/`));
index.html (the page)
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ローカルAIダッシュボード</title>
<style>
:root {
--bg: #f6f7f9; --card: #ffffff; --text: #1d2330; --muted: #667085; --line: #e3e6eb; --chip: #eef1f5; --hover: #f3f5f8;
--ok: #16a34a; --warn: #d97706; --bad: #dc2626; --idle: #a0a7b4; --busy: #2563eb;
--btn: #ffffff; --btn-line: #cfd5de; --primary: #2563eb; --primary-text: #fff; --danger: #dc2626;
}
@media (prefers-color-scheme: dark) {
:root { --bg: #111418; --card: #1a1e24; --text: #e6e9ee; --muted: #98a1ae; --line: #2a3039; --chip: #242a33; --hover: #20252c;
--idle: #5b6472; --btn: #1f242b; --btn-line: #3a414c; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.45 "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif; }
header { background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
h1 { font-size: 16px; margin: 0; }
h2 { font-size: 13px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.summary { display: flex; gap: 6px; }
.pill { background: var(--chip); border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.gpu { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bar { width: 140px; height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--busy); }
.updated { margin-left: auto; color: var(--muted); font-size: 12px; }
main { padding: 10px 16px 30px; }
#err { color: var(--bad); padding: 6px 16px; display: none; }
/* 起動中ピックアップ */
.pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; gap: 4px; min-width: 220px; max-width: 340px; }
.pcard.unhealthy, .pcard.foreign { border-left-color: var(--warn); }
.pcard.starting, .pcard.stopping { border-left-color: var(--busy); }
.pcard .top { display: flex; gap: 6px; align-items: center; font-weight: 600; }
.pcard .sub { font-size: 11px; color: var(--muted); }
.none { color: var(--muted); font-size: 12px; padding: 4px 0 10px; }
/* 一覧表 */
.tablewrap { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--card); }
td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.svc:hover td { background: var(--hover); }
tr.grp td { background: var(--chip); color: var(--muted); font-size: 11px; font-weight: 600; padding: 2px 8px; }
td.state { white-space: nowrap; }
td.name { white-space: nowrap; font-weight: 600; }
td.port { font-family: Consolas, monospace; white-space: nowrap; }
td.desc { color: var(--muted); font-size: 12px; max-width: 460px; }
td.desc div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.info { font-size: 12px; color: var(--muted); max-width: 260px; }
td.info div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.ops { white-space: nowrap; } td.ops .btns { flex-wrap: nowrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--idle); margin-right: 5px; vertical-align: 0; }
.running .dot, .dot.running { background: var(--ok); }
.unhealthy .dot, .foreign .dot, .dot.unhealthy, .dot.foreign { background: var(--warn); }
.starting .dot, .stopping .dot, .dot.starting, .dot.stopping { background: var(--busy); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.stxt { font-size: 12px; }
.stopped .stxt { color: var(--muted); }
.unhealthy .stxt, .foreign .stxt { color: var(--warn); }
.msg { font-size: 11px; } .msg.error { color: var(--bad); } .msg.done { color: var(--ok); }
button, a.btn { font: inherit; font-size: 12px; padding: 2px 8px; border-radius: 5px; border: 1px solid var(--btn-line); background: var(--btn); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button:disabled { opacity: .35; cursor: default; }
button.start { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
button.stop { border-color: var(--danger); color: var(--danger); }
button.more { border: none; background: none; padding: 0 4px; color: var(--muted); white-space: nowrap; }
.btns { display: inline-flex; gap: 4px; flex-wrap: wrap; }
tr.detail td { background: var(--hover); font-size: 12px; }
.paths { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.paths li { display: flex; gap: 6px; align-items: flex-start; }
code { font-family: Consolas, monospace; font-size: 12px; word-break: break-all; }
.copy { padding: 0 6px; font-size: 11px; flex: none; }
.dl { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; }
.dl > b { color: var(--muted); font-weight: 600; }
pre.log { background: var(--chip); padding: 8px; border-radius: 6px; max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 11px; margin: 0; }
details.others { margin-top: 14px; font-size: 12px; }
details.others summary { cursor: pointer; color: var(--muted); }
details.others td.cmd { word-break: break-all; color: var(--muted); }
@media (max-width: 900px) { td.desc, th.desc { display: none; } }
@media (max-width: 600px) { td.info, th.info { display: none; } .updated { margin-left: 0; } }
</style>
</head>
<body>
<header>
<h1>ローカルAIダッシュボード</h1>
<div class="summary" id="summary"></div>
<div class="gpu" id="gpu"></div>
<div class="updated" id="updated">読み込み中…</div>
</header>
<div id="err"></div>
<main>
<h2>起動中・要確認</h2>
<div id="pick" class="pick"></div>
<h2>すべてのサービス</h2>
<div class="tablewrap"><table>
<thead><tr><th>状態</th><th>サービス</th><th>ポート</th><th class="desc">説明</th><th class="info">情報</th><th>操作</th><th></th></tr></thead>
<tbody id="rows"></tbody>
</table></div>
<details class="others" id="others"></details>
</main>
<script>
const STATE_TEXT = { running: '起動中', stopped: '停止中', unhealthy: '応答なし', foreign: '別プロセスが使用中', starting: '起動処理中', stopping: '停止処理中' };
let data = null, timer = null;
const openRows = new Set(), openLogs = new Set();
let othersOpen = false;
const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
async function load() {
try {
data = await (await fetch('/api/status')).json();
document.getElementById('err').style.display = 'none';
render();
} catch (e) {
const el = document.getElementById('err'); el.style.display = 'block';
el.textContent = 'ダッシュボードのサーバーに接続できません。start.cmd を実行してください。';
}
clearTimeout(timer);
const busy = data?.status.some(s => s.state === 'starting' || s.state === 'stopping');
timer = setTimeout(load, busy ? 2000 : 5000);
}
function infoText(s) {
if (s.extra?.models) return s.extra.models.length ? 'モデル: ' + s.extra.models.map(m => `${m.name} (VRAM ${m.vramGB.toFixed(1)} GB)`).join(', ') : 'モデル未読み込み';
if (s.extra?.version) return 'v' + (typeof s.extra.version === 'string' ? s.extra.version : JSON.stringify(s.extra.version));
if (s.state === 'unhealthy' && s.health?.error) return s.health.error;
if (s.state === 'foreign' && s.process[0]) return `${s.process[0].name} (PID ${s.process[0].pid})`;
return '';
}
function jobMsg(s) {
if (!s.job) return '';
if (s.job.state === 'running') return `<div class="msg">${esc(s.job.message)}</div>`;
if (Date.now() - s.job.at < 120000) return `<div class="msg ${s.job.state}">${esc(s.job.message)}</div>`;
return '';
}
function buttons(d, s, st, defs, compact) {
const on = s.state === 'running';
const busy = s.state === 'starting' || s.state === 'stopping';
const blocker = d.conflicts.map(id => defs[id]).find(c => c && st[c.id]?.state !== 'stopped');
const canStop = !busy && (s.state === 'running' || s.state === 'unhealthy' || (d.stopByScript && s.state !== 'stopped' && s.state !== 'foreign'));
let h = d.open.filter(() => on).map(o => `<a class="btn" href="${esc(o.url)}" target="_blank" rel="noopener">${esc(o.label)}</a>`).join('');
if (!compact && d.canStart) h += `<button class="start" ${s.state === 'stopped' && !blocker ? '' : 'disabled'} title="${blocker ? esc(blocker.name + ' が起動中のため起動できません') : ''}" onclick="act('${d.id}','start')">起動</button>`;
h += `<button class="stop" ${canStop ? '' : 'disabled'} onclick="act('${d.id}','stop')">停止</button>`;
if (!compact) h += `<button onclick="toggleLog('${d.id}')">ログ</button>`;
return `<span class="btns">${h}</span>`;
}
function render() {
const st = Object.fromEntries(data.status.map(s => [s.id, s]));
const defs = Object.fromEntries(data.services.map(s => [s.id, s]));
const count = f => data.status.filter(f).length;
const warn = count(s => s.state === 'unhealthy' || s.state === 'foreign');
document.getElementById('summary').innerHTML =
`<span class="pill">起動中 ${count(s => s.state === 'running')}</span><span class="pill">停止 ${count(s => s.state === 'stopped')}</span>` +
(warn ? `<span class="pill" style="color:var(--warn)">要確認 ${warn}</span>` : '');
const g = data.gpu;
document.getElementById('gpu').innerHTML = g ? `${esc(g.name)} <div class="bar"><i style="width:${(g.used / g.total * 100).toFixed(0)}%"></i></div> VRAM ${(g.used / 1024).toFixed(1)} / ${(g.total / 1024).toFixed(1)} GB ・ 使用率 ${g.util}%` : '';
document.getElementById('updated').textContent = '更新 ' + new Date(data.time).toLocaleTimeString('ja-JP');
// 起動中ピックアップ(要確認・処理中も含める)
const active = data.services.filter(d => st[d.id].state !== 'stopped');
document.getElementById('pick').innerHTML = active.length ? active.map(d => {
const s = st[d.id], info = infoText(s);
return `<div class="pcard ${s.state}">
<div class="top"><span class="dot"></span>${esc(d.name)}<span class="sub" style="margin-left:auto">:${d.port}</span></div>
<div class="sub">${esc(STATE_TEXT[s.state])}${info ? ' ・ ' + esc(info) : ''}</div>${jobMsg(s)}
<div>${buttons(d, s, st, defs, true)}</div></div>`;
}).join('') : '<div class="none">起動中のサービスはありません</div>';
// 全量の表
let rows = '';
for (const grp of data.groups) {
rows += `<tr class="grp"><td colspan="7">${esc(grp.name)}</td></tr>`;
for (const d of data.services.filter(x => x.group === grp.id)) {
const s = st[d.id], info = infoText(s), open = openRows.has(d.id) || openLogs.has(d.id);
const deps = d.deps.length ? ' 使うもの: ' + d.deps.map(id => `${defs[id].name}`).join('、') : '';
rows += `<tr class="svc ${s.state}">
<td class="state"><span class="dot"></span><span class="stxt">${STATE_TEXT[s.state]}</span>${jobMsg(s)}</td>
<td class="name">${esc(d.name)}</td>
<td class="port">${d.port}</td>
<td class="desc"><div title="${esc(d.desc + deps)}">${esc(d.desc)}</div></td>
<td class="info"><div title="${esc(info)}">${esc(info)}</div></td>
<td class="ops">${buttons(d, s, st, defs, false)}</td>
<td><button class="more" onclick="toggleRow('${d.id}')" title="起動方法・プロセス">詳細${open ? '▾' : '▸'}</button></td>
</tr>`;
if (open) rows += `<tr class="detail"><td colspan="7">${detail(d, s, defs, st)}</td></tr>`;
}
}
document.getElementById('rows').innerHTML = rows;
for (const id of openLogs) showLog(id);
const o = document.getElementById('others');
o.innerHTML = `<summary>その他の待ち受けポート(${data.others.length})</summary>
<div class="tablewrap" style="margin-top:6px"><table><tr><th>ポート</th><th>アドレス</th><th>PID</th><th>プロセス</th><th>コマンドライン</th></tr>
${data.others.map(x => `<tr><td>${x.port}</td><td>${esc(x.addr)}</td><td>${x.pid}</td><td>${esc(x.name)}</td><td class="cmd">${esc(x.cmd)}</td></tr>`).join('')}</table></div>`;
o.open = othersOpen;
}
function detail(d, s, defs, st) {
const deps = d.deps.map(id => `<span style="margin-right:10px"><span class="dot ${st[id].state}"></span>${esc(defs[id].name)} :${defs[id].port}</span>`).join('');
return `<div class="dl">
<b>説明</b><div>${esc(d.desc)}</div>
${s.state === 'foreign' ? `<b>要確認</b><div style="color:var(--warn)">ポート ${d.port} を別のプログラムが使っています(下の「プロセス」)。このダッシュボードからは起動も停止もしません。</div>` : ''}
${deps ? `<b>使うもの</b><div>${deps}</div>` : ''}
<b>起動方法</b><ul class="paths">${d.launchers.map(p => `<li><code>${esc(p)}</code>${/^[A-Z]:\\/.test(p) ? `<button class="copy" onclick="copyText(this, ${esc(JSON.stringify(p.replace(/\(.*\)$/, '')))})">コピー</button>` : ''}</li>`).join('')}</ul>
${s.process.length ? `<b>プロセス</b><div>${s.process.map(p => `<div><code>PID ${p.pid}: ${esc(p.cmd)}</code></div>`).join('')}</div>` : ''}
${openLogs.has(d.id) ? `<b>ログ</b><pre class="log" id="log-${d.id}">読み込み中…</pre>` : ''}
</div>`;
}
async function act(id, action) {
const d = data.services.find(s => s.id === id);
if (action === 'stop') {
let msg = `「${d.name}」(:${d.port}) を停止します。`;
if (d.shared) msg += '\n\nこのエンジンは複数のアプリで共用しています。使っているアプリの声・会話が止まります。';
if (d.stopByScript) msg += '\n\n設定した停止用スクリプトを実行します。';
if (!confirm(msg)) return;
}
const r = await fetch(`/api/services/${id}/${action}`, { method: 'POST', headers: { 'x-dashboard': '1' } });
if (!r.ok) alert((await r.json()).error || '失敗しました');
load();
}
function toggleRow(id) {
if (openRows.has(id) || openLogs.has(id)) { openRows.delete(id); openLogs.delete(id); } else openRows.add(id);
render();
}
function toggleLog(id) {
if (openLogs.has(id)) openLogs.delete(id); else openLogs.add(id);
render();
}
async function showLog(id) {
const r = await fetch(`/api/services/${id}/log`).then(r => r.json());
const el = document.getElementById('log-' + id); if (!el) return;
el.textContent = `${r.path}\n\n${r.text}`;
el.scrollTop = el.scrollHeight;
}
function copyText(btn, text) {
navigator.clipboard.writeText(text).then(() => { btn.textContent = 'コピーしました'; setTimeout(() => btn.textContent = 'コピー', 1500); });
}
document.getElementById('others').addEventListener('toggle', e => { othersOpen = e.target.open; });
load();
</script>
</body>
</html>
start.cmd (start the dashboard and open it in the browser)
@echo off rem Start the dashboard and open it in the browser (just open it if already running) setlocal if not defined SERVICE_STATUS_PORT set "SERVICE_STATUS_PORT=3999" set "URL=http://127.0.0.1:%SERVICE_STATUS_PORT%/" curl -s -o nul "%URL%api/ping" && goto open where node >nul 2>nul || (echo Node.js was not found. Install Node.js first. & pause & exit /b 1) powershell.exe -NoProfile -Command "Start-Process -FilePath node -ArgumentList 'server.mjs' -WorkingDirectory '%~dp0' -WindowStyle Hidden" for /l %%i in (1,1,20) do ( curl -s -o nul "%URL%api/ping" && goto open timeout /t 1 /nobreak >nul ) echo Could not start the dashboard. Run "node server.mjs" in this folder to see the error. pause exit /b 1 :open start "" "%URL%"
stop.cmd (stop only the dashboard)
@echo off
rem Stop only the dashboard (services such as Ollama keep running)
setlocal
if not defined SERVICE_STATUS_PORT set "SERVICE_STATUS_PORT=3999"
powershell.exe -NoProfile -Command "$n = 0; Get-CimInstance Win32_Process -Filter \"Name='node.exe'\" | Where-Object { $_.CommandLine -match 'server\.mjs' -and (Get-NetTCPConnection -State Listen -LocalPort %SERVICE_STATUS_PORT% -ErrorAction SilentlyContinue | Where-Object OwningProcess -eq $_.ProcessId) } | ForEach-Object { Stop-Process -Id $_.ProcessId; $n++ }; if ($n) { 'Dashboard stopped.' } else { 'Dashboard is not running.' }"
pause
Summary
- Install Node.js, drop in five files, double-click
start.cmd - To fit your PC, edit lines 24-26 of
services.mjs. You can add as many services as you like - The code is free to use
If you run Ollama, AivisSpeech and image generation together on 8GB of VRAM, see how to free the VRAM used by Ollama and AivisSpeech. Together with this dashboard you can see what is using VRAM while you free it.
References
- Windows - Ollama (install location
%LOCALAPPDATA%\Programs\Ollama) - FAQ - Ollama (
OLLAMA_KEEP_ALIVE, default 5 minutes) - Startup Flags - ComfyUI (
--disable-auto-launch) - Modules: ECMAScript modules - Node.js (
import.meta.dirnamesince v20.11.0) - Get-NetTCPConnection - Microsoft Learn
Tested on: Windows 11, Node.js v26.13.1, GeForce RTX 2080 SUPER (8GB VRAM), Ollama (qwen3:4b-instruct-2507-q4_K_M), AivisSpeech Engine 1.0.0, ComfyUI 0.34.0. Checked on November 22, 2026.

コメント