fix: startup order, health endpoint, real metrics, settings warning, chart history
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -39,10 +39,14 @@ app.use('/api', apiRoutes);
|
||||
app.use(notFound);
|
||||
app.use(errorHandler);
|
||||
|
||||
app.listen(port, async () => {
|
||||
async function start() {
|
||||
await runMigrations();
|
||||
console.log(`⚡️ Server is running on port ${port}`);
|
||||
console.log(`🌍 Environment: ${process.env.NODE_ENV || 'development'}`);
|
||||
});
|
||||
app.listen(port, () => {
|
||||
console.log(`⚡️ Server is running on port ${port}`);
|
||||
console.log(`🌍 Environment: ${process.env.NODE_ENV || 'development'}`);
|
||||
});
|
||||
}
|
||||
|
||||
start().catch(console.error);
|
||||
|
||||
export default app;
|
||||
|
||||
@@ -7,6 +7,10 @@ import metricsRouter from './metrics';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/health', (req, res) => {
|
||||
res.json({ status: 'ok', timestamp: new Date().toISOString(), uptime: process.uptime() });
|
||||
});
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
res.json({
|
||||
message: 'Server Manager API',
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
import { Router, Request, Response } from 'express';
|
||||
import os from 'os';
|
||||
|
||||
const router = Router();
|
||||
|
||||
// GET /api/metrics - Get system metrics
|
||||
router.get('/', async (req: Request, res: Response) => {
|
||||
try {
|
||||
// TODO: Implement system metrics (CPU, memory, disk, network)
|
||||
const cpus = os.cpus();
|
||||
const loadAvg = os.loadavg()[0];
|
||||
const cpuUsage = Math.min(Math.round((loadAvg / cpus.length) * 100), 100);
|
||||
|
||||
const totalMem = os.totalmem();
|
||||
const freeMem = os.freemem();
|
||||
const usedMem = totalMem - freeMem;
|
||||
|
||||
res.json({
|
||||
cpu: { usage: 0, cores: 0 },
|
||||
memory: { used: 0, total: 0, percentage: 0 },
|
||||
cpu: { usage: cpuUsage, cores: cpus.length },
|
||||
memory: {
|
||||
used: Math.round(usedMem / 1024 / 1024),
|
||||
total: Math.round(totalMem / 1024 / 1024),
|
||||
percentage: Math.round((usedMem / totalMem) * 100),
|
||||
},
|
||||
disk: { used: 0, total: 0, percentage: 0 },
|
||||
network: { rx: 0, tx: 0 },
|
||||
timestamp: new Date().toISOString()
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Failed to fetch metrics' });
|
||||
@@ -21,11 +33,7 @@ router.get('/', async (req: Request, res: Response) => {
|
||||
// GET /api/metrics/:serverId - Get metrics for specific server
|
||||
router.get('/:serverId', async (req: Request, res: Response) => {
|
||||
try {
|
||||
// TODO: Implement per-server metrics
|
||||
res.json({
|
||||
serverId: req.params.serverId,
|
||||
metrics: {}
|
||||
});
|
||||
res.json({ serverId: req.params.serverId, metrics: {} });
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Failed to fetch server metrics' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user