Good afternoon, I would like to know how do I share a JSON object between different clusters. I currently have 3 clusters listening to three different ports. It is necessary to have an object saved in memory so that the three clusters can access the information of this object.
var express = require('express');
var net = require('net');
var Files = require('./lib/Files');
var app = express();
var port = 9000;
if(!myObject) {
// Cria o objeto na memória para que os outros sockets possam acessar
}
// Cria o Servidor
net.createServer(function (socket) {
if (config.STRLOG) {
console.log("Dispositivo Conectado: " + socket.remoteAddress + ":" + socket.remotePort);
}
socket.on('data', function (data) {
console.log(data);
});
socket.on('error', function (err) {
console.log('> SOCKET ERROR');
Files.SocketErrorLog(port, err);
console.log('------------------');
});
}).listen(port);
module.exports = app;