1

I'm relatively new to Linux (CentOS 7.2).

I'm trying to get my Hurtworld servers to run from systemd so I can use that nice restart=always feature. However to get multiple HW servers running, I remember I had to use individual tmux sessions.

This is one of my server start scripts:

#!/bin/bash
tmux new -d -s hurtworld5 '
./Hurtworld.x86_64 -batchmode \
-nographics \
-exec "host 15871;queryport 15872;servername [EU/US] <color=#f50>HURTCRAFT.com X1/VANILLA INF 25.05</color>  www.hurtcraft.com;maxplayers 120;addadmin 76561197987029828;structurecomplexitylimit 100000;targetfps 60;spawncooldown -0.1 20;combatlogtimeout 30;afkkicktime 260000;chatconnectionmessagesenabled 0;vehicledecaytime 86400;stakedeauthtime 518400" \
-logfile "gamelog.txt"
'tmux detach -s hurtworld5

These scripts work great for running the servers, but no matter what variation or extracts I use from this, I can't get it to launch through systemd. The best I've gotten is to have the actual HurtworldServer executable running, but it dies very quickly. I believe this is because I can't get it running through tmux this way, I think I remember having this exact problem trying to get the servers to work at all, until I got tmux going.

So I think I need to know how to launch an application from within a tmux session created by systemd. But then I anticipate a new problem in systemd not registering the server executable as the main process, so restart=always will only restart tmux if it dies?

Seems I'm stuck between a rock and a hard place and it's wrinkling my brain to oblivion so, if any of you great geniuses I've been learning from since I got this dedi, would like to help me solve this I'd be very grateful.

I'd be willing to use something like upstart or monit instead, if it would afford me the option of using my script and tracking the real process some other way, or such.

  • 3
    what issues do you have if you run the script without tmux? You can call the scripts as the systemd ExecStart=, but you're right in your concern that tmux would have to exit for systemd to start it again. That would be true of upstart as well (I haven't worked with monit, but probably it too). Your best bet would likely be to cut out tmux so your application isn't nested. – Centimane Jun 9 '16 at 15:44
  • Yea never understood why i need it, I think it's something to do with the particular game server (Hurtworld) not being able to have multiple instances. When I get it to run without tmux, either way, I watch the process in top and it doesn't behave like a normal tmux startup via the above script, it keeps 0.4 - 0.9% ram rather than going 1 - 3 % and then up from there as the save loads or creates, and the CPU stays at 100% of the thread as normal for a few seconds, but then it dies where normally it'd keep thrashing the cpu for up to a minute while it loads. Copied entire server dirs 4all, idk – Will Jackson Jun 9 '16 at 17:39
  • i'd copy my systemd script but i'm sure that part is ok because it runs the server, and i dont know how to copy From putty only to it. Is there a way i could open a tmux session that executes my .sh on ExecStart, being configured to kill the session if the process within it dies for any reason? then restart=always would still work through tmux? – Will Jackson Jun 9 '16 at 17:44
  • 1
    restart=always will only start the service again if the ExecStart exits. The only way to keep tmux and getting the restart to happen would be if tmux exists when the application exits. What sort of output do you get running the application itself? You could also try strace -e trace=network,stat,open,read ./Hurtworld.x86_64 ... to get an idea of what's going on (see man strace to get a sense of the syntax, strace can be hard to read, but it is the ultimate linux debugger). – Centimane Jun 9 '16 at 18:50
  • i have no idea how to get tmux to do that, so now i'm trying to get the basterd working without it. no line breaks here huh.. so this is my thing "[Unit] Description=HW1SVC After=network.target [Service] Type=simple User=root WorkingDirectory=/data/steamcmd/hw6 RootDirectory=/data/steamcmd/hw6 ExecStart=/data/steamcmd/hw6/Hurtworld.x86_64 -batchmode -nographics -exec autoexec.cfg -logfile "gamelog.txt" KillSignal=SIGINT TimeoutStopSec=30 Restart=always [Install] WantedBy=network.target" – Will Jackson Jun 10 '16 at 14:48
1

So i got it all working

[Unit]
Description=HW1SVC
After=network.target

[Service]
Type=simple
User=servers2
WorkingDirectory=/data/steamcmd/hw6/
ExecStart=/data/steamcmd/hw6/Hurtworld.x86_64 -batchmode -nographics -exec "autoexec.cfg" -logfile "gamelog.txt"
KillSignal=SIGINT
TimeoutStopSec=30
Restart=always

[Install]
WantedBy=network.target

this is the working .service file, incase it can help someone. i think the problem was ultimately caused by lack of workingdirectory parameter, but frankly i have no idea. many thanks to dave for trying to help !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.