jammsen / docker-palworld-dedicated-server

Docker container to easily provision and manage Palworld Dedicated Server
https://hub.docker.com/r/jammsen/palworld-dedicated-server
MIT License
911 stars 158 forks source link

Docker shutdown signal not passed on #14

Closed uncaught closed 9 months ago

uncaught commented 9 months ago

Have you read the Important information text above

Current behavior

When stopping the container, it seems to get killed after the stop_grace_period (default 10s).

Desired behavior

The stop signal should be passed onto the underlying service so that it shuts down cleanly within the grace period.

If the clean shutdown takes longer than 10 seconds, the image should set a higher grace period.

Links to screenshots

No response

To Reproduce

Steps to reproduce the behavior:

  1. Stop the container
  2. See it always stops after 10 seconds

Software setup

Hardware setup

Additional context

No response

0Downtime commented 9 months ago

This would be helpful since the server needs rebooted every 2 hours due to memory leak.

jammsen commented 9 months ago

Hey @uncaught Looks to me like this is the problem? https://docs.docker.com/compose/faq/#why-do-my-services-take-10-seconds-to-recreate-or-stop

uncaught commented 9 months ago

Yes, your entrypoint (servermanager.sh) needs to delegate the signals to the services it starts.

I don't know where PalServer.sh comes from, but if that handles a shutdown signal (the docker stop signal can be adjusted), then maybe this could already do the trick:

-    ./PalServer.sh "$START_OPTIONS"
+    exec ./PalServer.sh "$START_OPTIONS"

exec will replace the top level process, so the signals go there now.

Not sure if you need your own process running still though.

jammsen commented 9 months ago

Hey @uncaught the PalServer.sh comes with the server, it sets some unreal-engine things. PalServer.sh:

#!/bin/sh
UE_TRUE_SCRIPT_NAME=$(echo \"$0\" | xargs readlink -f)
UE_PROJECT_ROOT=$(dirname "$UE_TRUE_SCRIPT_NAME")
chmod +x "$UE_PROJECT_ROOT/Pal/Binaries/Linux/PalServer-Linux-Test"
"$UE_PROJECT_ROOT/Pal/Binaries/Linux/PalServer-Linux-Test" Pal "$@" 

But im working on a fix for that, a collegue of mine has something the might work and he was okay with me using it.

jammsen commented 9 months ago

Fix is applied in my local version:

Console

palworld-dedicated-server  | [S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
palworld-dedicated-server  | [S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
palworld-dedicated-server  | [S_API FAIL] Tried to access Steam interface STEAMAPPS_INTERFACE_VERSION008 before SteamAPI_Init succeeded.
palworld-dedicated-server  | [S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded.
^CGracefully stopping... (press Ctrl+C again to force)
[+] Stopping 1/1
 ✔ Container palworld-dedicated-server  Stopped                                                                                                     3.3s
palworld-dedicated-server exited with code 0
canceled

3.3 instead of 10 🚀

docker-compose logs -f

palworld-dedicated-server  | [S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
palworld-dedicated-server  | [S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
palworld-dedicated-server  | [S_API FAIL] Tried to access Steam interface STEAMAPPS_INTERFACE_VERSION008 before SteamAPI_Init succeeded.
palworld-dedicated-server  | [S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded.
palworld-dedicated-server  | FUnixPlatformMisc::RequestExitWithStatus
palworld-dedicated-server  | FUnixPlatformMisc::RequestExit
palworld-dedicated-server  | dlmopen steamservice.so failed: steamservice.so: cannot open shared object file: No such file or directory
palworld-dedicated-server  | Exiting abnormally (error code: 143)
palworld-dedicated-server  | Shutdown handler: cleanup.

This should do the trick i think. @uncaught

uncaught commented 9 months ago

3.3 seconds sounds good :)

jammsen commented 9 months ago

Please go ahead and test things. New Docker-Compose File is needed. You can find now examples in the README.md. The docker-compose.yml was removed because of dublicate code.

jammsen commented 9 months ago

If this issue is solved, please give me feedback on the patch and please consider giving me a Star here and on Docker-Hub.

jammsen commented 9 months ago

@uncaught Ping please read the last 2 comments and tell me things

uncaught commented 9 months ago

I've seen it, but can't test, yet. I've been shutting down the server via rcon lately and it's not running right now. (Damn memory leak ;) )

I've been using the updated script though already since yesterday.

I'm going to assume this is solved (until they change the name of PalServer-Linux-Test I guess ;) ).

jammsen commented 9 months ago

Well its their binary and their shell-script, up to them to manage that beast, hehe 👍