new classes based on json descriptor
This commit is contained in:
@ -13,7 +13,7 @@ app.use(express.static('public'));
|
||||
|
||||
// ---------- Redis subscriber ----------
|
||||
const redisClient = createClient({
|
||||
url: 'redis://172.17.0.1:6379'
|
||||
url: 'redis://192.168.37.1:6379'
|
||||
});
|
||||
redisClient.on('error', err => console.error('Redis error', err));
|
||||
|
||||
@ -25,7 +25,7 @@ redisClient.on('error', err => console.error('Redis error', err));
|
||||
await sub.connect();
|
||||
// Subscribe to the channel that sends host stats
|
||||
await sub.subscribe(
|
||||
['host_stats'],
|
||||
['host_metrics'],
|
||||
(message, channel) => { // <-- single handler
|
||||
let payload;
|
||||
try {
|
||||
@ -38,21 +38,6 @@ redisClient.on('error', err => console.error('Redis error', err));
|
||||
io.emit(channel, payload);
|
||||
}
|
||||
);
|
||||
// Subscribe to the channel that sends history stats
|
||||
await sub.subscribe(
|
||||
['history_stats'],
|
||||
(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