| 75 | const signalEventHandler = () => handleExit(1); |
| 76 | |
| 77 | const registerHooks = () => { |
| 78 | // Reference: https://nodejs.org/api/process.html#event-uncaughtexception |
| 79 | process.on('uncaughtExceptionMonitor', errorEventHandler); |
| 80 | // Reference: https://nodejs.org/api/process.html#event-unhandledrejection |
| 81 | process.on('unhandledRejection', errorEventHandler); |
| 82 | // Reference Signal Events: https://nodejs.org/api/process.html#signal-events |
| 83 | process.on('SIGINT', signalEventHandler); |
| 84 | process.on('SIGTERM', signalEventHandler); |
| 85 | process.on('exit', handleExit); |
| 86 | |
| 87 | if (signal) { |
| 88 | signal.addEventListener('abort', signalEventHandler); |
| 89 | } |
| 90 | }; |
| 91 | |
| 92 | const clearHooks = () => { |
| 93 | process.removeListener('uncaughtExceptionMonitor', errorEventHandler); |