Sending commands to child_process?
-
I have some code that starts a child process (server) via spawn () and sends data to the console:
var cp = require('child_process'); var child = cp.spawn('./server'); child.stdout.on('data', function(data) { console.log(data.toString()) });
The server is always running. I need to send a certain command there ("stop", "restart"), but this cannot be done.
You need to be able to send a command at any time.
How should I do it?Node.js Everett Baxter, Nov 8, 2019
0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!