feat: serve and command

This commit is contained in:
Cristina Poncela Cubeiro
2026-06-18 13:16:10 +02:00
parent 83e8c3d39b
commit 946b9c7dee
4 changed files with 52 additions and 12 deletions
+26
View File
@@ -0,0 +1,26 @@
import { existsSync, unlinkSync } from "node:fs";
import { getSocketPath } from "./config.ts";
import { handleIpcRequest } from "./handler.ts";
import { startIpcServer } from "./ipc/server.ts";
export async function serve(): Promise<void> {
const socketPath = getSocketPath();
const server = await startIpcServer(handleIpcRequest);
const cleanup = () => {
server.close();
if (existsSync(socketPath)) {
unlinkSync(socketPath);
}
};
process.on("SIGINT", () => {
cleanup();
process.exit(0);
});
process.on("SIGTERM", () => {
cleanup();
process.exit(0);
});
}