There are 2 processes on node.js, one running as root and one as a normal user, all on the same machine.
Purpose: to organize data exchange between processes, in the style of:

{"method":"reboot", "params":{"timeout":0}} 

and it is natural to get an answer about the result of execution or any other information
Now implemented by raising the socket server and serializing data in json. But the time has come to add all this, and I would like to find a more correct way, if there is one.
thank

upd: The machine is rather weak and I would not want to raise http api for such purposes

  • Can be made through Unix sockets - pnp2000
  • one
    Somewhere was about the exchange. Read about "data exchange" between processes: sockets, pipe (pipes, named pipes), shared memory. - nick_n_a

1 answer 1

It is possible through a Unix socket, there are many examples, here is one

 var client = net.createConnection("/tmp/mysocket"); client.on("connect", function() { ... do something when you connect ... }); client.on("data", function(data) { ... do stuff with the data ... }); 
  • Thank. Now it is already done. I thought maybe there is some other solution) - ErrorMan
  • If you don’t want to fence it, this is the best option, you can run another from Cluster from one module and share events, but I don’t think the difference will be very noticeable - pnp2000