Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

stdin and stdout no longer works for Linux Garry's Mod SRCDS server #2343

Open ertug2 opened 8 years ago

ertug2 commented 8 years ago

Hello,

For some odd reason srcds_run no longer sends the stdin and stdout onto srcds_linux which has broken how our Web Console system works on our control panel. This current system never broke before which is odd.

Sincerely,

Ertug Erdogan

ertug2 commented 8 years ago

After further investigation,

the issue seems to lie with srcds_linux itself. No matter what I do, I am unable to send command through the stdin pipe. This has never broke before with Garry's Mod and works absolutely fine with all other source games and even basic test applications like a shell or a program.

After the latest GMod update, it just hangs when I try to send in anything to it.

Not trying to rush you :). I just wanted to give you a update.

I assume that this will take a very long time to even be looked at since nobody except for us actually takes advantage of the native pipe to send console commands to the server. It's just a pain on our end to use RCON since it relies on TCP/IP and fails to connect and send our 'anti crash commands' to the server if it is crashing.

Thanks again.

Sincerely,

Ertug Erdogan

AusHick commented 8 years ago

Can confirm this has been a long-standing issue. Running the latest Debian.

ertug2 commented 8 years ago

I'm also running Debian by the way. This did only come up after the latest update. Thanks.

AusHick commented 8 years ago

This has been a thing for a rather long time. Far before the latest update.

I'm assuming you're using TCAdmin2?

ertug2 commented 8 years ago

We have our own custom control panel deployed (GMCPanel) which took advantage of the direct stdin (Subprocess) for console purposes. We have been using this for years with our clients without any issues only until the latest update. It worked fine on a outdated build (before December) but as soon as it was updated, it no longer works.

AusHick commented 8 years ago

TCA2 uses similar practices for reading directly from the console, but it has been broken for a long time, and through many dev builds. Not sure how many live builds it's been like this.

Definitely something to look into considering it was functional at a previous point.

8BallBomBom commented 8 years ago

I have been using TCA2 with this feature on Debian 7 and 8 for input and output on the web console for a while, it hasn't been broken for a long time, the latest update broke it.

This actually forced me to change the web console over to RCON instead.

AusHick commented 8 years ago

Have you been running live or dev branch? Because I know for a fact it's older than the last 3 dev branch updates. Live branch I don't use much and I couldn't say for certain. On Jan 19, 2016 6:16 PM, "Johnathon Paul Weaver" notifications@github.com wrote:

I have been using TCA2 with this feature for input and output on the web console for a very long time, it hasn't been broken for a long time, the latest update broke it.

This actually forced me to change the web console over to RCON instead.

— Reply to this email directly or view it on GitHub https://github.com/Facepunch/garrysmod-issues/issues/2343#issuecomment-173019141 .

8BallBomBom commented 8 years ago

Live for years. Up until the update in December everything was tested and working without issues. I even prevented upgrades on a few servers just to test.

ertug2 commented 8 years ago

I have also been using Live all the time. The latest update in December definitely broke it.

AusHick commented 8 years ago

Well at least that narrows this down slightly. There's been a bunch of dev updates since then. I couldn't tell you when it happened on there.

I hide in my dev server, my other staff handles the live servers. On Jan 19, 2016 6:21 PM, "ertug2" notifications@github.com wrote:

I have also been using Live all the time. The latest update in December definitely broke it.

— Reply to this email directly or view it on GitHub https://github.com/Facepunch/garrysmod-issues/issues/2343#issuecomment-173020277 .

8BallBomBom commented 8 years ago

No worries. Would just be nice to have a fix out asap. This makes the web console return double results from RCON or nothing at all in some cases. Gets very annoying to use compared to what it was like before.

ertug2 commented 8 years ago

TCAdmin is TCAdmin. There's a reason that I made my own.

RCon gives me no issues other than being stupidly slow when compared to stdin.

Synergyst commented 8 years ago

Still no updates on the issue..? I'm running Debian 7 Wheezy and I started experiencing the issue after that update too. I really hope this is something which is resolvable.

bilenkonito commented 8 years ago

This is still a problem and it is a major breaker for some of us. Please, provide a solution.

ertug2 commented 8 years ago

I was forced to implement local only RCon. it isn't as bad as you may think but it is still at least two times slower.

bilenkonito commented 8 years ago

I was forced to implement local only RCon. it isn't as bad as you may think but it is still at least two times slower.

Unfortunately, that only solves stdin, not stdout which is what I need

ertug2 commented 8 years ago

Condebug (makes a console.log) gives me absolutely no issues at all.

I even have a client pushing 128 players with it on with absolutely no performance impacts.

bilenkonito commented 8 years ago

This still doesn't work for me because I am reusing the same server files for multiple instances. To be more clear, I am working on a server backend to provide gmod server instances as a service on-demand, rather than the traditional model of leaving the server running 24/7. Everything so far works fine (including our matchmaking system: https://rustracers.xyz/match-making) but this bug seriously impacts my capacity to communicate with the SRCDS process from Python.

ertug2 commented 8 years ago

I would personally discourage that. You should not have multiple instances writing to the same files at once. At least when sqlite (sv.db) and some text based databases (ulx). .

I'm sure it's definitely possible, there would just be major issues down the road.

bilenkonito commented 8 years ago

I am not using SQLite for anything, we're using the mysqloo module and mariadb, which allows us to integrate against our website. As mentioned, everything works wonderfuly and as expected, save for this bug that prevents me from parsing output for events.

ertug2 commented 8 years ago

I see. Well this issue has been unsolved for a while. I would not expect any attention to be given to this.

Good luck with that project nonetheless.

bilenkonito commented 8 years ago

Use socat

This is a very nasty non-scalable and non-maintainable solution to a problem that shouldn't exist in the first place. This has been known since 2005, about time to fix it. I am cloud orchestrating our package into a farm on Azure and AWS, and every dependency adds overhead and maintenance that I simply don't want to deal with.

The issue is that srcds_linux prints directly to /dev/ttyX instead of stdout (same for stdin in reverse), which is a terrible practice.

To be clear, what I am doing is far from a 5 minute server setup, it is something that as far as I know, hasn't been done yet properly (if it has been done at all, which I doubt). The size of this project is huge in comparison with pretty much anything else in Gmod, and I cannot be relying on cringe-worthy solutions like pseudo-TTYs, specially when this problem is absolutely trivial to resolve having the SRCDS source code.

PS: I am using srcds_linux in non-shell mode (I have rebuilt the bash environment variables required by srcds_linux in Python and I am passing them as env in Popen, which works fine save for stdout). I cannot use srcds_game as this wrapper is even more laughable than srcds_linux and does not kill its children when I kill the parent (it just stays defunct forever).

EDIT: Known since 2005, as I said: http://forums.steampowered.com/forums/showthread.php?t=293619

xaviergmail commented 6 years ago

Easy solution with python:

master_fd, slave_fd = pty.openpty()
proc = subprocess.Popen(sys.argv[1:], stdout=slave_fd, stderr=slave_fd, stdin=slave_fd)

use os.read to get output and os.write to send input on master_fd

Edit: You need to do some over-my-head TTY magic to get the above to work flawlessly: https://stackoverflow.com/a/43012138

lukbukkit commented 5 years ago

I've took your solutions a step further and created a small program using Go. It runs srcds_linux and logs its output to stdout. To use it, download it and in your start script replace srcds_linux or srcds_run with source_logger.

For more see: https://github.com/LukWebsForge/SourceLogger