I'm trying to make a front-end for my privately hosted Counter-Strike Global Offensive servers, on the front-end when I hit run server, everything works great and the server starts up and logs to console. But how can I view information like the server IP address, players in the server, and other things?
This is what I have so far for running the server:
router.post('/create', function(req, res) {
console.log(req.body);
var child = spawn('/home/steam/steamcmd/csgo/srcds_run -game csgo -console +game_type 0 +game_mode 0 +host_workshop_collection 249376192 -tickrate 128 +maxplayers 20')
child.stderr.on('data', function(err) {
console.log(err);
});
child.stdin.on('data', function(chunk) {
console.log(chunk);
});
child.stdout.on('data', function(chunk) {
});
});
Like for e.g. if I used a paid server host I would have a control panel where I could see server IP, restart / stop view players in game and other things. I hope this was clear enough and sorry if it was poorly written. I'm not sure how else to word this.
Does the server accept input once it has started? If so you can write to it using
child.stdin.write('my command\n');
Otherwise you're going to have to query it using something like gamedig
来源:https://stackoverflow.com/questions/30071370/how-do-i-interact-with-a-newly-created-server-created-with-child-process-spawn