I am currently making a Minecraft server to be controlled with Node JS and child process. However, when trying to execute a minecraft command from node to be passed to the server, the server doesn't respond at all. After tinkering with it a bit I found that while the server is running properly, the server process is not connected with the parent node process. This is the code I am using:
//Spawn and run the server
var svEnv = cp.spawn("java", [
"-Xms4096M",
"-Xmx4096M",
"-jar",
"server.jar",
"nogui"
], {
shell: false,
detached: true,
cwd: `${config.server.directoryPath}`,
stdio: "pipe"
});
svEnv.unref();
To test executing a command I simply use svEnv.stdin.write(`${cmd}\n`). I've noticed what when detached is set to false, the commands execute fine, however when detached is enabled the server ignores the inputs, yet the callback function still executes when the write is done executing. I checked the connection properties of the server process:
svEnv.stdin.writable -> true
svEnv.connected -> false
I'm guessing that the detached option being set to true disconnects the IPC channels between the child and the parent.
Is it possible to have the IPC channels still be functional when the child process is detached?
note: I am using windows 10