* Stop the server. In daemon mode this triggers graceful shutdown of every * connected session; in direct mode it mirrors the pre-#411 behavior (close * cg, exit). Proxy mode never routes through here — the proxy exits itself.
()
| 263 | * cg, exit). Proxy mode never routes through here — the proxy exits itself. |
| 264 | */ |
| 265 | stop(): void { |
| 266 | if (this.stopped) return; |
| 267 | this.stopped = true; |
| 268 | if (this.ppidWatchdog) { |
| 269 | clearInterval(this.ppidWatchdog); |
| 270 | this.ppidWatchdog = null; |
| 271 | } |
| 272 | if (this.livenessWatchdog) { |
| 273 | this.livenessWatchdog.stop(); |
| 274 | this.livenessWatchdog = null; |
| 275 | } |
| 276 | if (this.daemon) { |
| 277 | void this.daemon.stop('stop()'); |
| 278 | // Daemon.stop calls process.exit; nothing else to do. |
| 279 | return; |
| 280 | } |
| 281 | if (this.session) { |
| 282 | this.session.stop(); |
| 283 | this.session = null; |
| 284 | } |
| 285 | if (this.engine) { |
| 286 | this.engine.stop(); |
| 287 | this.engine = null; |
| 288 | } |
| 289 | process.exit(0); |
| 290 | } |
| 291 | |
| 292 | /** Single-process stdio MCP session — the pre-issue-#411 code path. */ |
| 293 | private async startDirect(reason: string): Promise<void> { |
no test coverage detected