I create a small game server manager in Node.js; he is currently launching the game by spawning through child_process :
var server = spawn(cmd, args, { cwd: 'something' });
While the manager continues to work, I can execute commands and process child elements as I would like. However, keep in mind that my manager crashes or is closed. How would I then reconnect to the previously spawned child process (which still worked while the manager was not working)? I can store pidfiles to try connecting again based on pid; but I'm not sure how to get a child_process object with access to stdio child objects.
I really wish it were possible; any help is appreciated, thanks!
Please Note :: Game servers are property, some examples are Minecraft, Source DS, etc. Suppose I do not have access to the source.
EDIT
After reading some source code from node child_process , it looks like if you specify a property in the parameters with the name stdinStream , stdoutStream or stderrStream , it should just open the socket for it. (See Lines 428 - 496 ). So the problem is, how can I stop spawning from actually creating caviar and instead, it just sets its values based on the given pid and the streams that I transmit. (I would get stdinStream by running fs.createWriteStream('/proc/PID/fd/0'); which should work, since fd is created as a channel.)
Chad
source share