()
| 200 | |
| 201 | export function setupCleanupHandlers(cleanupFn) { |
| 202 | const cleanup = async () => { |
| 203 | try { |
| 204 | await cleanupFn() |
| 205 | } catch (error) { |
| 206 | log('ERROR', '清理失败:', error.message) |
| 207 | } |
| 208 | process.exit(0) |
| 209 | } |
| 210 | |
| 211 | process.on('SIGINT', cleanup) |
| 212 | process.on('SIGTERM', cleanup) |