full server dashboard working
This commit is contained in:
@ -25,8 +25,9 @@ try {
|
||||
}
|
||||
|
||||
const API_PORT = config.custom_api_port || 5000; // fallback to 5000
|
||||
const API_HOST = config.docker_gateway || '192.168.37.1'; // fallback IP
|
||||
const API_HOST = config.api_bind_ip || '192.168.37.1'; // fallback IP
|
||||
const API_BASE = `http://${API_HOST}:${API_PORT}`;
|
||||
console.log('API URL:', API_BASE);
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// ---------- 2. Socket.io ------------------------------------------------
|
||||
@ -87,6 +88,37 @@ redisClient.on('error', err => console.error('Redis error', err));
|
||||
}
|
||||
);
|
||||
|
||||
// Subscribe to the channel that sends host stats
|
||||
await sub.subscribe(
|
||||
['client_summary'],
|
||||
(message, channel) => {
|
||||
let payload;
|
||||
try {
|
||||
payload = JSON.parse(message); // message is a JSON string
|
||||
} catch (e) {
|
||||
console.error(`Failed to parse ${channel}`, e);
|
||||
return;
|
||||
}
|
||||
io.emit(channel, payload);
|
||||
}
|
||||
);
|
||||
|
||||
// Subscribe to the channel that sends host stats
|
||||
await sub.subscribe(
|
||||
['client_hostnames'],
|
||||
(message, channel) => {
|
||||
let payload;
|
||||
try {
|
||||
payload = JSON.parse(message); // message is a JSON string
|
||||
} catch (e) {
|
||||
console.error(`Failed to parse ${channel}`, e);
|
||||
return;
|
||||
}
|
||||
io.emit(channel, payload);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
sub.on('error', err => console.error('Subscriber error', err));
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user