Search code examples
node.jslinuxchild-processspawn

Missing information from Child Process in Node


i'm running a Counter-Strike: Source Dedicated Server with Node.js through the Child Process module like this:

var spawn = require('child_process').spawn;
const server = spawn('./srcds_run', ['-game cstrike', '+map de_dust2', '+maxplayers 10'])
server.on('error', function (error){
    console.log(error);
});
server.stdout.on('data', (data) => {
    console.log(`server stdout:\n${data}`);
});
server.stderr.on('data', (data) => {
    console.error(`server stderr:\n${data}`);
});

The server runs perfectly fine, i can join to it and play, but i got missing information that the server must return in the console.

If i run the server mannualy from the console it show all this info. But if i run it fron this Node app only shows this info (I used pastebin because there was too many lines to paste directly here)

I'm missing the most important info that i want, which are all the lines that start with the L character, they are the server logs that tells me all what's happening in every match.

I read the documentation and i couldn't find anything about it, and also tryed with listeners like message and log but any of them retrieve info.

Any idea how get all this info? Thanks!


Solution

  • The solution was:

    1. This Node.js program just execute the server with Child Process
    2. Once the server is running the communication is made directly throught the RCON Protocol

    Simple as that, i don't need to build a gigantic program from scratch, with the RCON Protocol i can read all the output and send commands just like i do from the ingame console.