()
| 237 | |
| 238 | export function setupCleanupHandlers(cleanupFn) { |
| 239 | const cleanup = async () => { |
| 240 | try { |
| 241 | await cleanupFn() |
| 242 | } catch (error) { |
| 243 | log('ERROR', 'Cleanup failed:', error.message) |
| 244 | } |
| 245 | process.exit(0) |
| 246 | } |
| 247 | |
| 248 | process.on('SIGINT', cleanup) |
| 249 | process.on('SIGTERM', cleanup) |