| 109 | public abstract logger: Logger |
| 110 | |
| 111 | public constructor() { |
| 112 | process.on("SIGINT", () => this._onDispose.emit("SIGINT")) |
| 113 | process.on("SIGTERM", () => this._onDispose.emit("SIGTERM")) |
| 114 | process.on("exit", () => this._onDispose.emit(undefined)) |
| 115 | |
| 116 | this.onDispose((signal, wait) => { |
| 117 | // Remove listeners to avoid possibly triggering disposal again. |
| 118 | process.removeAllListeners() |
| 119 | |
| 120 | // Try waiting for other handlers to run first then exit. |
| 121 | this.logger.debug("disposing", field("code", signal)) |
| 122 | wait.then(() => this.exit(0)) |
| 123 | setTimeout(() => this.exit(0), 5000) |
| 124 | }) |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Ensure control over when the process exits. |