MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / stop

Method stop

server/src/http.ts:8704–8759  ·  view source on GitHub ↗

* Stop the server gracefully

()

Source from the content-addressed store, hash-verified

8702 * Stop the server gracefully
8703 */
8704 async stop(): Promise<void> {
8705 logger.info('Stopping HTTP server');
8706
8707 // Only stop background services that were started on this machine
8708 if (this.isWorker) {
8709 jobScheduler.stopAll();
8710
8711 import('./scheduled/seat-request-reminders.js').then(({ stopSeatRequestReminders }) => {
8712 stopSeatRequestReminders();
8713 }).catch(() => {});
8714
8715 import('./scheduled/auto-provision-digest.js').then(({ stopAutoProvisionDigest }) => {
8716 stopAutoProvisionDigest();
8717 }).catch(() => {});
8718
8719 import('./luma/sync.js').then(({ stopLumaSync }) => {
8720 stopLumaSync();
8721 }).catch(() => {});
8722 }
8723
8724 // Drain tracked background work before closing connections
8725 const { drainBackgroundWork } = await import('./services/brand-enrichment.js');
8726 logger.info('Draining background work');
8727 await drainBackgroundWork();
8728 logger.info('Background work drained');
8729
8730 // Close HTTP server
8731 if (this.server) {
8732 await new Promise<void>((resolve, reject) => {
8733 this.server!.close((err) => {
8734 if (err) {
8735 logger.error({ err }, "Error closing HTTP server");
8736 reject(err);
8737 } else {
8738 logger.info("HTTP server closed");
8739 resolve();
8740 }
8741 });
8742 });
8743 }
8744
8745 // Shutdown PostHog client (flush pending events)
8746 const { shutdownPostHog } = await import('./utils/posthog.js');
8747 await shutdownPostHog();
8748
8749 // Shutdown OpenTelemetry logging (flush pending logs)
8750 const { shutdownOtelLogs } = await import('./utils/otel-logs.js');
8751 await shutdownOtelLogs();
8752
8753 // Close database connection
8754 logger.info('Closing database connection');
8755 await closeDatabase();
8756 logger.info('Database connection closed');
8757
8758 logger.info('Graceful shutdown complete');
8759 }
8760
8761 private async prewarmCaches(agents: any[]): Promise<void> {

Calls 8

stopSeatRequestRemindersFunction · 0.85
stopAutoProvisionDigestFunction · 0.85
stopLumaSyncFunction · 0.85
drainBackgroundWorkFunction · 0.85
shutdownPostHogFunction · 0.85
shutdownOtelLogsFunction · 0.85
closeDatabaseFunction · 0.85
stopAllMethod · 0.80

Tested by

no test coverage detected