(signal: string, exitCode: number)
| 469 | } |
| 470 | |
| 471 | async function shutdown(signal: string, exitCode: number): Promise<void> { |
| 472 | if (isShuttingDown) { |
| 473 | return |
| 474 | } |
| 475 | |
| 476 | isShuttingDown = true |
| 477 | process.off("SIGINT", onSigint) |
| 478 | process.off("SIGTERM", onSigterm) |
| 479 | process.off("uncaughtException", onUncaughtException) |
| 480 | process.off("unhandledRejection", onUnhandledRejection) |
| 481 | clearKeepAliveInterval() |
| 482 | |
| 483 | if (!useJsonOutput) { |
| 484 | console.log(`\n[CLI] Received ${signal}, shutting down...`) |
| 485 | } |
| 486 | |
| 487 | await disposeHost() |
| 488 | if (jsonEmitter) { |
| 489 | await jsonEmitter.flush() |
| 490 | } |
| 491 | await flushStdout() |
| 492 | process.exit(exitCode) |
| 493 | } |
| 494 | |
| 495 | process.on("SIGINT", onSigint) |
| 496 | process.on("SIGTERM", onSigterm) |
no test coverage detected