| 53 | } |
| 54 | |
| 55 | function uncaughtHandler(err: Error, origin: NodeJS.UncaughtExceptionOrigin) { |
| 56 | logger.error(`stopping process: Uncaught exception (origin: ${origin}):`, err); |
| 57 | // A process with live server listeners never exits "naturally": after an uncaught exception we'd |
| 58 | // limp on in an undefined state (#8811). Exit after a short delay so winston can flush its |
| 59 | // transports (calling `process.exit()` immediately may lose log lines, see |
| 60 | // https://github.com/winstonjs/winston/issues/1504#issuecomment-1033087411), and let the load |
| 61 | // balancer replace the instance. |
| 62 | process.exitCode = 1; |
| 63 | setTimeout(() => process.exit(1), 1000); |
| 64 | } |
| 65 | |
| 66 | // Parse command line arguments |
| 67 | const appArgs = parseArgsToAppArguments(process.argv); |