UNPKG

@codai/cbd

Version:

Codai Better Database - High-Performance Vector Memory System with HPKV-inspired architecture and MCP server

103 lines • 4.86 kB
import { CBDCloudEnhancedService } from './universal/CBDCloudEnhancedService.js'; import dotenv from 'dotenv'; // Load environment variables dotenv.config(); class ModernCBDCloudServer { service; server = null; isShuttingDown = false; constructor() { this.service = new CBDCloudEnhancedService(); this.setupGracefulShutdown(); } async start() { try { console.log('šŸš€ Starting CBD Universal Database - Cloud Enhanced Service...'); console.log('šŸ“‹ Environment:', process.env.NODE_ENV || 'development'); console.log('šŸ”§ Node.js version:', process.version); // Display cloud configuration console.log('šŸŒ„ļø Multi-Cloud Configuration:'); console.log(' AWS Region:', process.env.AWS_REGION || 'us-east-1'); console.log(' Azure Region:', process.env.AZURE_REGION || 'eastus'); console.log(' GCP Region:', process.env.GCP_REGION || 'us-central1'); // Initialize service this.service = new CBDCloudEnhancedService(); const app = await this.service.initialize(); // Configure server const port = process.env.PORT || 4180; this.server = app.listen(port, () => { console.log('āœ… CBD Universal Cloud-Enhanced Service is running'); console.log(`🌐 Server: http://localhost:${port}`); console.log('šŸ“Š Available Paradigms: 5 (Document, Vector, Graph, Key-Value, Time-Series)'); console.log('šŸŒ„ļø Cloud Features: Multi-Cloud Intelligence, Dynamic Selection, Performance Analytics'); console.log(''); console.log('šŸ“ Key Endpoints:'); console.log(` Health Check: http://localhost:${port}/health`); console.log(` Statistics: http://localhost:${port}/stats`); console.log(` Cloud Status: http://localhost:${port}/cloud/status`); console.log(` Cloud Analytics: http://localhost:${port}/cloud/analytics`); console.log(` Document API: http://localhost:${port}/document/*`); console.log(` Vector API: http://localhost:${port}/vector/*`); console.log(` Graph API: http://localhost:${port}/graph/*`); console.log(` KV API: http://localhost:${port}/kv/*`); console.log(` TimeSeries: http://localhost:${port}/timeseries/*`); console.log(''); console.log('šŸ’” Ready for multi-cloud operations. Press Ctrl+C to stop.'); }); // Set server timeout for long-running operations if (this.server) { this.server.timeout = 30000; } // Setup graceful shutdown this.setupGracefulShutdown(); } catch (error) { console.error('āŒ Failed to start CBD Universal Cloud-Enhanced Service:', error); process.exit(1); } } setupGracefulShutdown() { const shutdown = async (signal) => { if (this.isShuttingDown) return; this.isShuttingDown = true; console.log(`\nšŸ”„ Received ${signal}. Starting graceful shutdown...`); try { console.log('šŸŒ„ļø Disconnecting from cloud services...'); // Cloud disconnection would happen here console.log('šŸ—„ļø Stopping CBD Universal Service...'); if (this.server) { this.server.close(() => { console.log('āœ… Server closed successfully'); }); } else { console.log('āœ… Service shutdown complete'); } console.log('āœ… CBD Universal Cloud-Enhanced Service stopped gracefully'); process.exit(0); } catch (error) { console.error('āŒ Error during shutdown:', error); process.exit(1); } }; process.on('SIGTERM', () => shutdown('SIGTERM')); process.on('SIGINT', () => shutdown('SIGINT')); process.on('uncaughtException', (error) => { console.error('āŒ Uncaught Exception:', error); shutdown('uncaughtException'); }); process.on('unhandledRejection', (reason, promise) => { console.error('āŒ Unhandled Rejection at:', promise, 'reason:', reason); shutdown('unhandledRejection'); }); } } // Start the server const server = new ModernCBDCloudServer(); server.start().catch(error => { console.error('āŒ Failed to start server:', error); process.exit(1); }); //# sourceMappingURL=start-cloud-enhanced.js.map