5
Good afternoon, I would like to know how to share a JSON object between different clusters. I currently have 3 clusters listening to three different doors. And I need 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;
Is this file static? or should it be accessed and/or modified by different servers? Is there a database?
– Sergio
The idea is that when instantiated the object, the information is searched in the bank. After instantiated it is put into memory so that the other sockets can access it.
– Leonardo Luís Röpke