Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion npm/kubernetes-mcp-server/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,26 @@ const resolveBinaryPath = () => {
}
};

childProcess.execFileSync(resolveBinaryPath(), process.argv.slice(2), {
const child = childProcess.spawn(resolveBinaryPath(), process.argv.slice(2), {
stdio: 'inherit',
});

const handleSignal = () => (signal) => {
console.log(`Received ${signal}, terminating child process...`);
if (child && !child.killed) {
child.kill(signal);
}
};

['SIGTERM', 'SIGINT', 'SIGHUP'].forEach((signal) => {
process.on(signal, handleSignal(signal));
});

child.on('close', (code, signal) => {
if (signal) {
console.log(`Child process terminated by signal: ${signal}`);
process.exit(128 + (signal === 'SIGTERM' ? 15 : signal === 'SIGINT' ? 2 : 1));
} else {
process.exit(code || 0);
}
});
2 changes: 1 addition & 1 deletion pkg/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func Serve(ctx context.Context, mcpServer *mcp.Server, staticConfig *config.Stat
defer cancel()

sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGHUP, syscall.SIGTERM)

serverErr := make(chan error, 1)
go func() {
Expand Down
Loading