1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00
Files
nttgin-BGPalerter/index.js
Massimo Candela 37faf5f24b init
2019-06-14 18:04:20 +02:00

36 lines
659 B
JavaScript

// import os from "os";
import config from "./config";
import cluster from "cluster";
import WebSocket from "ws";
import Consumer from "./consumer";
if (cluster.isMaster) {
let bufferSize = config.bufferSize;
const worker = cluster.fork();
const ws = new WebSocket("wss://ris-live.ripe.net/v1/ws/");
ws.on('message', (message) => {
worker.send(message);
});
ws.on('open', () => {
ws.send(JSON.stringify({
type: "ris_subscribe",
data: config.wsParams
}));
});
ws.on('close', function close() {
console.log('Disconnected');
});
} else {
new Consumer()
}