This commit is contained in:
CN-JS-HuiBai
2026-04-06 17:56:36 +08:00
parent bc8414df3d
commit da722ee07e

View File

@@ -1021,8 +1021,14 @@ async function broadcastMetrics() {
}
}
// Start server and services
async function start() {
try {
console.log('🔧 Initializing services...');
// Ensure DB is ready before starting anything else
await checkAndFixDatabase();
// Start services
checkAndFixDatabase();
latencyService.start();
const REFRESH_INT = parseInt(process.env.REFRESH_INTERVAL) || 5000;
@@ -1033,3 +1039,10 @@ server.listen(PORT, HOST, () => {
console.log(` 📊 Server running at http://${HOST === '0.0.0.0' ? 'localhost' : HOST}:${PORT}`);
console.log(` ⚙️ Configure Prometheus sources at http://${HOST === '0.0.0.0' ? 'localhost' : HOST}:${PORT}/settings\n`);
});
} catch (err) {
console.error('❌ Server failed to start:', err.message);
process.exit(1);
}
}
start();