STEAM GROUP
Linux Game Server Managers linuxgsm
STEAM GROUP
Linux Game Server Managers linuxgsm
92
IN-GAME
683
ONLINE
Founded
February 9, 2015
[ARK] Automatic restart script?
Hello!

We are running an ARK Server on Debian with scripts from gameservermanagers.com
Everything works pretty well but it looks like we are stucking on a "basic" thing.

We are trying to automate the daily restarts but there we have some issues.

I want to do it with cronjobs. To run the restartscript.

Last try was with:
55 5 * * * ./arkserver stop 57 5 * * * ./arkserver start

Yesterday i tryed
00 6 * * * ./arkserver restart

But in both cases the server is shutting down but it dont came back online.

Are there some hints i missed?
< >
Showing 1-14 of 14 comments
UltimateByte Feb 25, 2016 @ 9:51am 
Your syntax doesn't look like anything we advise.
Also, if running multiple servers, consider root cronjobs (watch the syntax, it's different)

https://github.com/dgibbs64/linuxgsm/wiki/Automation
Thanks now it seems to work.
But now after a restart, the server is shown as online with ./arkserver details but is not shown in HLSW or Ingame Serverlist
UltimateByte Feb 28, 2016 @ 3:46am 
Probably a port issue. Firewall, port redirection, port already in use and stuff.
Last edited by UltimateByte; Feb 28, 2016 @ 3:46am
Eightball Mar 26, 2016 @ 8:15am 
late to the party but maybe this could help someone else. I believe you need to be running those commands as user arkserver, not root
UltimateByte Mar 26, 2016 @ 5:12pm 
Of course.
poitnzz May 5, 2016 @ 3:00pm 
You need to add a pause between stop and start. Otherwise, the server does not have time to release ports.
You can see it in log : CreateBoundSocket: ::bind couldn't find an open port between 27015 and 27015

So restart function is not functional at this moment.
@ultimatebyte do you think there is a good fix to resolve the ark server restart issue? or will it just be to add a sleep 10 if using ark server?
UltimateByte May 9, 2016 @ 5:06pm 
That's a good question. I host an Ark server currently, but not for me, and it just has a force-update per week... So there is no such issue in our case. The only time i got fancy things was after the owner run an update and restarts the server a few times, there were 3 ark processes, with only one with more than 100% CPU usage, so i closed the lowest CPU usage, problem solved... Didn't investigate further for now.
Mazer May 9, 2016 @ 5:33pm 
sleep might not be the solution if the process locking the port isn't being shutdown correctly.

I'd propose adding an additional check on line 157 of command_stop.sh:

Check if the gamename is "ARK: Survivial Evolved". If so, invoke a new fn_stop_ark3.

fn_stop_ark3 would simply be:
# Grab the QueryPort. There are two locations to grab this from. # First start with the parameters from the parms line port=$(grep ^parms= ${servername} |\ awk -F"QueryPort=" '{print $2}' |\ sed "s/[^[:digit:].*].*//g" ) # In the above line, ${servername} would expand to the arkserver script # I don't know if that's correctly expanded, but it's my first pass at this. # # The first part pulls the parms line from the arkserver script # The awk cuts everything from the parms line after "QueryPort=" # which should be the port specification and more cruft. # So kill the cruft with the sed command, stripping everything # after the first nondigit encountered to the end of the line. # What's left in the port variable should be the clean port used # for the server. # This port is what isn't getting freed correctly. # # Omitted: if port wasn't defined in the parms line, then grab it from # ~/serverfiles/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini # This is already a 'tl:dr' post. The code is similar. # # Next, grab what's listening on that port (if anything) if [[ ${#port} -gt 0 ]] ; then pid=$(lsof -ti UDP:${port}) # might need netstat here if lsof isn't installed. # netstat variation: # pid=(netstat -nap 2>/dev/null | grep udp | grep :${port}[[:space:]] | rev |\ # awk '{print $1}' | rev | cut -d\/ -f1) # # Check for a valid pid let pid+=0 # turns an empty string into a valid number, '0', # and a valid numeric pid remains unchanged. if [[ $pid -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then # Kill the process still listening on that port. kill -9 $pid fi # end if for pid range check fi # end if for port check
The socket should close immediately, freeing up the port for the subsequent call to command_start.sh (called from line 103 of core_functions.sh, where the restart functionality is implemented).

I could have finger-flubbed some of the above commands while adding comments, but the logic should all be there.

The same code could be expanded to grab "Port" from GameUserSettings.ini to clean those processes, too (which don't seem to get cleaned from the stop command either).
Last edited by Mazer; May 10, 2016 @ 9:09am
[LGSM] KnightLife May 12, 2016 @ 12:36pm 
Decent. This needs to move to the github page. I could do with someone intergrating this in to the development branch ready for release of the developemtn branch soon. So I welcome volunteers :)
Mazer May 12, 2016 @ 6:07pm 
Ok. I'll work on a pull request. I need to do more error handling around the kill statement anyway (to handle situations where there's a process owned by another user on that port, so the kill fails) and add the dive into the GameUserSettings.ini file in the event that the QueryPort isn't specified on the parms line of the script.
I was running it since this topic started with a pause between stop and start. Its running without problems. It takes about 20sek from running the stop script until port is closed.
At all it would be nice to add a feature to your script to kill the port fast. Would save some time playing with crontabs ^^
[LGSM] KnightLife May 13, 2016 @ 1:10pm 
The server will just close when its ready ark is a large server to I would excpect it to take time to save and close etc. So a restart or a start should instead check that ark has closed down and not start until it have confirmed this.
Mazer May 18, 2016 @ 8:24pm 
Originally posted by sloxx. aka Tigermaus:
I was running it since this topic started with a pause between stop and start. Its running without problems. It takes about 20sek from running the stop script until port is closed.
I am not seeing the port ever close using sleep.

Can you double check the output of:
netstat -nap | grep Shoo

From what I am seeing, the only way to reliably stop or restart the service is to kill the pid that's listening on the port before/after tmux has been closed.

Here's a session showing that even after waiting 20 minutes, the ports never closed.[pastebin.com]
Last edited by Mazer; May 18, 2016 @ 9:18pm
< >
Showing 1-14 of 14 comments
Per page: 1530 50

Date Posted: Feb 25, 2016 @ 5:58am
Posts: 14