()
| 78 | |
| 79 | function setupExitWatchdog(serverList: ServerList) { |
| 80 | const handleExit = async () => { |
| 81 | setTimeout(() => process.exit(0), 15000); |
| 82 | try { |
| 83 | // SessionManager within each server handles session cleanup |
| 84 | await serverList.closeAll(); |
| 85 | } catch (error) { |
| 86 | console.error("Error during cleanup:", error); |
| 87 | } |
| 88 | process.exit(0); |
| 89 | }; |
| 90 | |
| 91 | process.stdin.on("close", handleExit); |
| 92 | process.on("SIGINT", handleExit); |