Merge pull request #216 from stefanobaldo/fix/stdin-close-cleanup
fix(server): close Python backend and exit gracefully when stdin closes
This commit is contained in:
@@ -64,6 +64,12 @@ function parseCommandLineArgs(args: string[]) {
|
|||||||
* Setup graceful shutdown handlers
|
* Setup graceful shutdown handlers
|
||||||
*/
|
*/
|
||||||
function setupGracefulShutdown(server: KiCADMcpServer) {
|
function setupGracefulShutdown(server: KiCADMcpServer) {
|
||||||
|
// Handle stdin close (EOF) when parent process exits
|
||||||
|
process.stdin.on("close", async () => {
|
||||||
|
logger.info("process.stdin closed. Shutting down...");
|
||||||
|
await shutdownServer(server);
|
||||||
|
});
|
||||||
|
|
||||||
// Handle termination signals
|
// Handle termination signals
|
||||||
process.on("SIGINT", async () => {
|
process.on("SIGINT", async () => {
|
||||||
logger.info("Received SIGINT signal. Shutting down...");
|
logger.info("Received SIGINT signal. Shutting down...");
|
||||||
|
|||||||
Reference in New Issue
Block a user