@kya-os/mcp-i
Version:
The TypeScript MCP framework with identity features built-in
35 lines (34 loc) • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.startHttpServer = startHttpServer;
const cli_icons_1 = require("../utils/cli-icons");
const spawn_process_1 = require("../utils/spawn-process");
const child_process_1 = require("child_process");
let httpServerProcess = null;
function spawnHttpServer() {
const process = (0, child_process_1.spawn)("node", ["dist/http.js"], {
stdio: "inherit",
shell: true,
});
(0, spawn_process_1.watchdog)(process);
return process;
}
async function killProcess(process) {
process.kill("SIGKILL");
await new Promise((resolve) => {
process.on("exit", resolve);
});
}
async function startHttpServer() {
if (!httpServerProcess) {
console.log(`${cli_icons_1.yellowArrow} Starting http server`);
// first time starting the server
httpServerProcess = spawnHttpServer();
}
else {
console.log(`${cli_icons_1.yellowArrow} Restarting http server`);
// restart the server
await killProcess(httpServerProcess);
httpServerProcess = spawnHttpServer();
}
}