* 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.
()
| 321 | * cg, exit). Proxy mode never routes through here — the proxy exits itself. |
| 322 | */ |
| 323 | stop(): void { |
| 324 | if (this.stopped) return; |
| 325 | this.stopped = true; |
| 326 | if (this.ppidWatchdog) { |
| 327 | clearInterval(this.ppidWatchdog); |
| 328 | this.ppidWatchdog = null; |
| 329 | } |
| 330 | if (this.livenessWatchdog) { |
| 331 | this.livenessWatchdog.stop(); |
| 332 | this.livenessWatchdog = null; |
| 333 | } |
| 334 | if (this.daemon) { |
| 335 | void this.daemon.stop('stop()'); |
| 336 | // Daemon.stop calls process.exit; nothing else to do. |
| 337 | return; |
| 338 | } |
| 339 | if (this.session) { |
| 340 | this.session.stop(); |
| 341 | this.session = null; |
| 342 | } |
| 343 | if (this.engine) { |
| 344 | this.engine.stop(); |
| 345 | this.engine = null; |
| 346 | } |
| 347 | process.exit(0); |
| 348 | } |
| 349 | |
| 350 | /** Single-process stdio MCP session — the pre-issue-#411 code path. */ |
| 351 | private async startDirect(reason: string): Promise<void> { |
no test coverage detected