/** * Phase 3 Startup Configuration * * Add these lines to server/index.mjs before app.listen(): * * 1. Setup performance endpoint * 2. Setup deferred Meilisearch indexing * 3. Start server with monitoring */ // ============================================================================ // BEFORE app.listen() - Add these lines: // ============================================================================ // Setup performance monitoring endpoint setupPerformanceEndpoint(app, performanceMonitor, metadataCache, meilisearchCircuitBreaker); // Setup deferred Meilisearch indexing (non-blocking) const { scheduleIndexing } = await setupDeferredIndexing(vaultDir, fullReindex); // Start server const server = app.listen(PORT, '0.0.0.0', () => { console.log(`šŸš€ ObsiViewer server running on http://0.0.0.0:${PORT}`); console.log(`šŸ“ Vault directory: ${vaultDir}`); console.log(`šŸ“Š Performance monitoring: http://0.0.0.0:${PORT}/__perf`); // Schedule background indexing (non-blocking) scheduleIndexing(); console.log('āœ… Server ready - Meilisearch indexing in background'); }); // Graceful shutdown process.on('SIGINT', () => { console.log('\nšŸ›‘ Shutting down server...'); server.close(() => { console.log('āœ… Server shutdown complete'); process.exit(0); }); }); // ============================================================================ // NOTES: // ============================================================================ // - The server starts immediately without waiting for Meilisearch indexing // - Indexing happens in the background via setImmediate() // - If indexing fails, it retries after 5 minutes // - Performance metrics available at /__perf endpoint // - Cache hit rate should reach > 80% after 5 minutes of usage // - Circuit breaker protects against cascading failures