Add a Desktop dashboard and text status command for disk space, RAM, CPU and Intel integrated graphics. Include visibility-driven sampling, tests, development tooling, and installation documentation.
28 lines
1.0 KiB
JavaScript
28 lines
1.0 KiB
JavaScript
// Development-only live visual test. Never loaded by the installed plugin.
|
|
import { createServer } from "vite"
|
|
import solid from "vite-plugin-solid"
|
|
import { monitor } from "../dist/metrics.js"
|
|
|
|
const server = await createServer({
|
|
configFile: false,
|
|
plugins: [solid(), {
|
|
name: "local-monitor-preview",
|
|
configureServer(server) {
|
|
server.middlewares.use("/__metrics", async (_request, response) => {
|
|
try {
|
|
response.setHeader("Content-Type", "application/json")
|
|
response.setHeader("Cache-Control", "no-store")
|
|
response.end(JSON.stringify(await monitor.snapshot()))
|
|
} catch {
|
|
response.statusCode = 503
|
|
response.end('{"error":"Collection failed"}')
|
|
}
|
|
})
|
|
},
|
|
}],
|
|
server: { host: "127.0.0.1", port: 5098, strictPort: true },
|
|
})
|
|
await server.listen()
|
|
console.log("System Monitor live preview: http://127.0.0.1:5098/preview.html")
|
|
for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, async () => { await server.close(); process.exit(0) })
|