feat: add daemon server skeleton with health check endpoint

This commit is contained in:
2026-08-12 20:45:25 +08:00
parent 3810661098
commit 19d67cfda9
3 changed files with 59 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import http from 'node:http';
import { healthRoute } from './routes/health.js';
const routes = [healthRoute];
export function startServer(port: number): Promise<http.Server> {
return new Promise((resolve) => {
const server = http.createServer((req, res) => {
for (const route of routes) {
if (route(req, res)) return;
}
res.writeHead(404, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ ok: false, error: { code: 'INTERNAL', message: 'not found' } }));
});
server.listen(port, '127.0.0.1', () => {
console.log(`[daemon] VisionL daemon started on http://127.0.0.1:${port}`);
resolve(server);
});
});
}
// Direct start when running as script
const port = parseInt(process.env.VISIONL_PORT || '9527', 10);
startServer(port);