如何与使用 child_process.spawn 创建的新创建的服务器交互 [英] How do I interact with a newly created server, created with child_process.spawn

查看:97
本文介绍了如何与使用 child_process.spawn 创建的新创建的服务器交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我私人托管的反恐精英全球攻势服务器制作前端,当我点击运行服务器时,在前端,一切正常,服务器启动并记录到控制台.但是如何查看服务器IP地址、服务器中的玩家等信息?

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) {

    });

});

喜欢例如如果我使用付费服务器主机,我将有一个控制面板,我可以在其中查看服务器 IP、重新启动/停止查看游戏中的玩家和其他内容.我希望这足够清楚,如果写得不好,我很抱歉.我不知道还能怎么说.

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');

否则你将不得不使用类似 gamedig

Otherwise you're going to have to query it using something like gamedig

这篇关于如何与使用 child_process.spawn 创建的新创建的服务器交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆