fix(mcp): call shutdownMetrics on serve graceful shutdown

The supported scrape target (gitnexus serve) was leaking the Prometheus
exporter HTTP server on SIGINT/SIGTERM, leading to EADDRINUSE on restart.
Mirror the existing pattern in mcp/server.ts.
This commit is contained in:
Nathan Hangen 2026-05-10 21:24:58 -04:00
parent 2d0a4ffef2
commit a101f0e3be

View file

@ -1832,6 +1832,10 @@ export const createServer = async (port: number, host: string = '127.0.0.1') =>
await cleanupMcp();
await closeLbug();
await backend.disconnect();
try {
const { shutdownMetrics } = await import('../mcp/metrics.js');
await shutdownMetrics();
} catch {}
const { flushLoggerSync } = await import('../core/logger.js');
flushLoggerSync();
process.exit(0);