Personal computing discussed

Moderators: renee, SecretSquirrel, notfred

 
Heiwashin
Maximum Gerbil
Topic Author
Posts: 4815
Joined: Wed Dec 13, 2006 1:21 pm
Location: Denham Springs, LA

Screen

Mon May 01, 2017 7:54 pm

Is it reasonable to run game servers in screen so they run in background and I can access the in out. Does it increase risk of instability? Is it just plain bad practice?

I rented a vds and started putting dedicated game servers on it for reasons I'm still not sure of yet. I think I just wanted something new to tinker with and learn because their is no goal.

I've already learned a lot of new stuff. The whole piping thing seems amazing. In my research I'm currently paused at figuring out how to set up the server to start as a service but use pipes so I can issue commands and read logs. It's going fine except I haven't found a way to do both at the same time, if that's even possible.

At any rate I keep coming back screen being such an easy solution. My natural instincts tell me I shouldn't be running the server in anything else though. Am I right?
Looking for Knowledge wrote:
When drunk.....
I want to have sex, but find I am more likely to be shot down than when I am sober.
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Screen

Mon May 01, 2017 9:35 pm

Screen (and its cousin tmux) are what you use when you have a CLI command that you can interact with, but which you also want to persist if the terminal session disconnects. Sounds like you're using the right tool here.

In recent years tmux has been a bit better maintained than screen (which had essentially become abandonware). I believe someone has picked up maintenance of screen again though, so I don't think there's a strong case for one over the other.

You can launch screen in the background with a command already running in it: screen -d -m <command>

As far as setting it up as a service goes, you can either read up on how to do init scripts, or just use the quick and dirty hack of launching it from /etc/rc.local (probably want to use su to launch it under a non-privileged user ID so it isn't running as root).
Nostalgia isn't what it used to be.
 
Heiwashin
Maximum Gerbil
Topic Author
Posts: 4815
Joined: Wed Dec 13, 2006 1:21 pm
Location: Denham Springs, LA

Re: Screen

Mon May 01, 2017 11:31 pm

Well right now i've got it starting with systemd as a service under it's own user. That keeps it running in the background and i can at least see that it's still running but i can't access the input/output. I was looking into setting up some pipes to send the output to a text and give me some avenue to send inputs but that's where i'm stuck.

So i haven't actually tried the screen\tmux yet, but if you guys here think it's a reasonable solution i'll go for it. It'd certainly be a heck of a lot easier and would solve all my problems. I just thought it'd be hacky to run it inside of something else or something.
Looking for Knowledge wrote:
When drunk.....
I want to have sex, but find I am more likely to be shot down than when I am sober.
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Screen

Tue May 02, 2017 5:03 am

If the program is designed to be accessed interactively (i.e. accepts interactive commands from the keyboard), I wouldn't say it is hacky at all. For something that just logs output (which is how most services work...) yeah it would be more sensible to just pipe the output to a log file.

The main risk to stability is probably PEBCAK... e.g. accidentally hitting ^C while connected to the screen/tmux session the service is running in. :wink:
Nostalgia isn't what it used to be.
 
Glorious
Gerbilus Supremus
Posts: 12343
Joined: Tue Aug 27, 2002 6:35 pm

Re: Screen

Tue May 02, 2017 8:01 am

Heiwashin wrote:
So i haven't actually tried the screen\tmux yet, but if you guys here think it's a reasonable solution i'll go for it. It'd certainly be a heck of a lot easier and would solve all my problems. I just thought it'd be hacky to run it inside of something else or something.


Pretty much every guide you'll find about running a dedicated game server on linux involves using screen/tmux, whether CS:GO, Minecraft, etc...

So I'd say it's not just reasonable, but pretty much a de facto standard. :wink:
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: Screen

Tue May 02, 2017 8:13 am

Just in case I wasn't clear enough before (and knowing that you've already set it up to launch via systemd), you can modify the way the service gets launched in one of two ways:

1. If you just want to see the output, redirect the output to a log file.

2. If you want/need to interact with it directly via keyboard and terminal window, have systemd launch screen or tmux instead, with the server process running inside it. Then you can attach to the screen/tmux session whenever you want, and detach/disconnect without killing it.
Nostalgia isn't what it used to be.
 
Glorious
Gerbilus Supremus
Posts: 12343
Joined: Tue Aug 27, 2002 6:35 pm

Re: Screen

Tue May 02, 2017 8:30 am

JBI wrote:
2. If you want/need to interact with it directly via keyboard and terminal window, have systemd launch screen or tmux instead, with the server process running inside it. Then you can attach to the screen/tmux session whenever you want, and detach/disconnect without killing it.


I think the reason the guides all go for option #2 is that you can still send commands via the server instance command line. That is, you don't need to have admin privileges in a game client to remotely control the server, you can just attach to the terminal multiplexer (whether screen or tmux) and directly issue commands there.
 
Heiwashin
Maximum Gerbil
Topic Author
Posts: 4815
Joined: Wed Dec 13, 2006 1:21 pm
Location: Denham Springs, LA

Re: Screen

Tue May 02, 2017 9:37 am

Today I'll set everything up to run in a tmux then. Thanks a bunch.
Looking for Knowledge wrote:
When drunk.....
I want to have sex, but find I am more likely to be shot down than when I am sober.
 
Heiwashin
Maximum Gerbil
Topic Author
Posts: 4815
Joined: Wed Dec 13, 2006 1:21 pm
Location: Denham Springs, LA

Re: Screen

Wed May 03, 2017 2:46 pm

So I tried slipping tmux and screen into the service file on seperate occasions but the strangest thing happens. It looks like tmux starts, opens the game server, and then completely closes. No sign of it in top, no sessions available. However the game server keeps running. :x Screen just plain does nothing.

Don't give the secret away, I'll find this damned gremlin yet.
Looking for Knowledge wrote:
When drunk.....
I want to have sex, but find I am more likely to be shot down than when I am sober.
 
Heiwashin
Maximum Gerbil
Topic Author
Posts: 4815
Joined: Wed Dec 13, 2006 1:21 pm
Location: Denham Springs, LA

Re: Screen

Wed May 03, 2017 7:54 pm

The problem has to be related to the fact that I'm starting everything on its own user. I did manage to find the tmux process with P's aux grep. I think there's some kind of weirdness going on with it storing the socket in tmp. I'd be willing to bet if I just changed everything to my user it would work fine but I won't dagnabbit. Ima make this work.


GOT IT. Tested tmux under my name, it made files for socket. The other one didn't have access to those files so it made a totally different set which the default list didn't check. Literally spent about 4 hours total on this. Pumped about a successful problem solved :wink:
Looking for Knowledge wrote:
When drunk.....
I want to have sex, but find I am more likely to be shot down than when I am sober.

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On