Modifying this so it moves buffers into string.

This commit is contained in:
Alexander Blair
2017-03-05 16:00:35 -08:00
parent c9b0869e2c
commit a34e8c6ceb
3 changed files with 38 additions and 21 deletions
+18 -21
View File
@@ -41,27 +41,7 @@ app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
if (cluster.isMaster) {
let numWorkers = require('os').cpus().length;
console.log('Master cluster setting up ' + numWorkers + ' workers...');
for (let i = 0; i < numWorkers; i++) {
let worker = cluster.fork();
workerList.push(worker);
}
cluster.on('online', function (worker) {
console.log('Worker ' + worker.process.pid + ' is online');
});
cluster.on('exit', function (worker, code, signal) {
console.log('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal);
console.log('Starting a new worker');
worker = cluster.fork();
workerList.push(worker);
});
} else {
server.listen(8001);
if (!cluster.isMaster) {
// Init the ZMQ listeners here.
sock.connect('tcp://127.0.0.1:3000');
sock.connect('tcp://127.0.0.1:3001');
@@ -72,6 +52,21 @@ if (cluster.isMaster) {
sock.subscribe('');
}
require('sticky-cluster')(
// server initialization function
function (callback) {
// don't do server.listen(), just pass the server instance into the callback
callback(server);
},
// options
{
concurrency: require('os').cpus().length,
port: 8001,
debug: false,
env: function (index) { return { stickycluster_worker_index: index }; }
}
);
// SocketIO Routes
// ===============
io.on('connection', (socket) => {
@@ -84,6 +79,8 @@ io.on('connection', (socket) => {
// The following is the ZMQ logic. Pray to whatever deity you like.
sock.on('message', function(topic, message) {
topic = topic.toString();
message = message.toString();
/*
Registered ZMQ Messages:
miner_hash_graph - Hash graphs updated