escapingnetwork / core-keeper-dedicated

Dockerfile for automated build of a Core Keeper Dedicated Server
https://hub.docker.com/r/escaping/core-keeper-dedicated
MIT License
97 stars 26 forks source link

Propagate signals to launch.sh and fully await shutdown #47

Closed Oldsouldier closed 1 week ago

Oldsouldier commented 2 weeks ago

This fully completes the passing of docker shutdown signals to the game executable. (Completes #46) Prior to this, the signals were not being passed from entry.sh to launch.sh. Another alternative is to merely source entry.sh from launch.sh and make launch.sh the actual dockerfile command.

Also, after some testing, i noticed some lost progress when shutting down the world. Delaying the termination of xvfb by waiting within the trap handler seemed to eliminate this problem for me.

Oldsouldier commented 2 weeks ago

Another possible explanation of why this works better is that the wait at the bottom of launch.sh is interrupted by the signals received (once exec was added to entry.sh), so the 1 second sleep was not enough wait for the process to shut down prior to the container terminating. The additional wait in the trap handler provides the necessary delay.

arguser commented 1 week ago

Hello @Oldsouldier, thank you for the PR. Yesterday we merged a PR adding tini for passing signals, thanks to @solareon

Doesn't that solves this issue?

arguser commented 1 week ago

What do you think GOAT @Micke90s ?

Oldsouldier commented 1 week ago

@arguser It was part of the solution, but does not produce the desired outcome. I added echo statements in the trap handler in launch.sh and they were not printing until i added the exec call in entry.sh.

Furthermore, even after the signal was being caught, i noticed loss of progress when shutting down due to the wait call being interrupted by the signal (my current theory). This is a known behavior of wait. The additional call to wait allows time for a complete shutdown, which is the entire point of the signal passing in the first place.

Micke90s commented 1 week ago

@Oldsouldier: Thank you for the detailed explanation and your pull request. Works perfect :+1: Just saw that the server even would wait for the last player to leave before stop.