arkmanager / ark-server-tools

Set of server tools used to manage ARK: Survival Evolved servers on Linux
MIT License
680 stars 144 forks source link

not saving world when server shutdown #1147

Open christian1211 opened 4 years ago

christian1211 commented 4 years ago

I'm using the system services for arkmanager. When I shutdown the server (VM), the instances doesn't save the world before shutdown.

Here my service files:

arkmanager.service

[Unit]
Description=Starts and stops all ark server instances
After=network.target

[Service]
ExecStart=/usr/local/libexec/arkmanager/arkmanager.init start
ExecStop=/usr/local/libexec/arkmanager/arkmanager.init stop
Type=forking
RemainAfterExit=yes
TimeoutSec=120
Restart=always

[Install]
WantedBy=multi-user.target

arkmanager@.service

[Unit]
Description=Daemon to start an ark server instance

[Service]
User=steam
Group=steam
ExecStart=/usr/local/bin/arkmanager useconfig %i start
ExecStop=/usr/local/bin/arkmanager useconfig %i stop
Type=forking
Restart=always
RestartSec=30
KillMode=process
TimeoutSec=120

I think it's my fault but I'm not able to find the problem.

klightspeed commented 4 years ago

Try changing the command in ExecStart in arkmanager@.service from start to start --no-background, and changing the Type from forking to exec. In this case, ExecStop should not be required, as a SIGTERM should cleanly shut down the server.

christian1211 commented 4 years ago

I changed arkmanager@.service like this:

[Unit]
Description=Daemon to start an ark server instance

[Service]
User=steam
Group=steam
ExecStart=/usr/local/bin/arkmanager useconfig %i start --no-background
#ExecStop=/usr/local/bin/arkmanager useconfig %i stop
Type=exec
Restart=always
RestartSec=30
KillMode=process
TimeoutSec=120

Seems not working. I tried shutdown and reboot inside the os and shutdown and reboot from hypervisor but in all cases the world has not been saved.

klightspeed commented 4 years ago

Does it work if you use arkmanager stop @all? Does it work if you use killall -INT ShooterGameServer?

If the answer is no to both, then that suggests that something (for example a mod) is preventing the normal world save on graceful shutdown.

christian1211 commented 4 years ago

arkmanager stop @all - the worlds have been saved killall -INT ShooterGameServer - the worlds have been saved

So with both commands the worlds have been saved.

btw. the os is Debian 10.

klightspeed commented 4 years ago

Does it save the world at all (e.g. when you run arkmanager rconcmd @instance saveworld)?

Does journalctl -u 'arkmanager*' reveal anything?

christian1211 commented 4 years ago

arkmanager rconcmd @instance saveworld - yes, the world has been saved

journalctl -u 'arkmanager*' shows one error for each instance:

/etc/systemd/system/arkmanager@.service:9: Failed to parse service type, ignoring: exec

klightspeed commented 4 years ago

You say you have Debian Buster (Debian 10), yet your systemd does not support Type=exec (as documented in https://manpages.debian.org/buster/systemd/systemd.service.5.en.html).

It looks like Type=exec was added in systemd v240 (see https://github.com/systemd/systemd/commit/79905a246d645d21633f09f564b3672d5085a85c), and Buster is supposed to include systemd v241

christian1211 commented 4 years ago

Ok my fault: I had Ubuntu 18.04 (I thought it was Debian 10, sorry!) before which doesn't support Type=exec as it has systemd v237 included. I updated everything to Ubuntu 20.04 now, which has systemd v245 included. The error message disappeared.

But still it's not saving the world at reboot or shutdown.

christian1211 commented 4 years ago

I uncommented ExecStop again in arkmanager@.service and added --saveworld and it seems working like this.

[Unit]
Description=Daemon to start an ark server instance

[Service]
User=steam
Group=steam
ExecStart=/usr/local/bin/arkmanager useconfig %i start --no-background
ExecStop=/usr/local/bin/arkmanager useconfig %i stop --saveworld
Type=exec
Restart=always
RestartSec=30
KillMode=process
TimeoutSec=120

Maybe before it didn't work because of the older systemd version. Thank you!

klightspeed commented 4 years ago

stop --saveworld does an explicit rconcmd saveworld.

It sounds almost as if the script is not being permitted to send a signal to the game server, which results in the script and game server being killed with SIGKILL after the 120 second timeout expires.

christian1211 commented 4 years ago

But this means that after the shutdown command the service would wait 120 seconds to exit. After I use the shutdown or reboot command it exits immediately within maybe 2 or 3 seconds, there is no waiting for timeout. I have no idea where to look for the issue. :/