| 241 | try { process.stdout.write((typeof obj === 'string' ? obj : JSON.stringify(obj)) + '\n'); } catch { /* host gone */ } |
| 242 | }; |
| 243 | const shutdown = (): void => { |
| 244 | if (shuttingDown) return; shuttingDown = true; |
| 245 | try { daemonSocket?.destroy(); } catch { /* ignore */ } |
| 246 | try { engine?.stop(); } catch { /* ignore */ } |
| 247 | process.exit(0); |
| 248 | }; |
| 249 | const ensureEngine = (): Promise<void> => { |
| 250 | if (!engine) engine = deps.makeEngine(); |
| 251 | if (!engineReady) engineReady = engine.ensureInitialized(deps.root).catch(() => { /* degraded */ }); |