()
| 31 | let isShuttingDown = false; |
| 32 | |
| 33 | const cleanup = () => { |
| 34 | if (isShuttingDown) return; |
| 35 | isShuttingDown = true; |
| 36 | |
| 37 | console.log(`Shutting down server (PID: ${process.pid})...`); |
| 38 | try { |
| 39 | transport.close(); |
| 40 | } catch (error) { |
| 41 | console.error(`Error closing transport (PID: ${process.pid}):`, error); |
| 42 | } |
| 43 | console.log(`Server closed (PID: ${process.pid})`); |
| 44 | process.exit(0); |
| 45 | }; |
| 46 | |
| 47 | transport.onerror = (error: Error) => { |
| 48 | console.error(`Transport error (PID: ${process.pid}):`, error); |