Answer the question
In order to leave comments, you need to log in
How to share data between 3 running processes in Node.js?
Created a cluster and divided into 3 processes.
1 - main
2 and 3 (the so-called bots that must exchange information with the main process).
Could you tell me how to implement the exchange of information in real time?
Answer the question
In order to leave comments, you need to log in
https://github.com/RIAEvangelist/node-ipc
https://github.com/sidorares/node-dbus
There are plenty of options and it is not necessary to use third-party modules, you can work with sockets (this is how the node-ipc, node-dbus and many other modules designed for these purposes work) through the built-in "net" module.
https://nodejs.org/api/net.html
Or, alternatively, launch child processes from the main process and communicate with them like this.
https://nodejs.org/api/child_process.html (child_process.fork())
const bot1= require('child_process').fork('./bot1.js');
bot1.send({param: value});
bot1.on('message', function (message) {
//...
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question