TIL: godot/unity/unreal don’t let you write code for when a process lifecycle signal is sent to the running process. That means if you’re running a godot game server process as a systemd service and decide to “systemctl stop” the running server instance, you can’t write GDscript to catch that “graceful shutdown request (SIGTERM)” signal!
One way to add this software characteristic is to wrap your game server process in a bash script, “trap” SIGTERM signal, and from there use a communicate-to-process technique on the running server process. Common techniques include ‘just write a file and check for its existence in GDscript’ and ‘send a udp or http(tcp) request to the running server instance.’ Security can be achieved through generating something random in bash and passing it as command line arguments to the game server. YMMV.
Note: these game engines do have application process hooks for window signals like when you press “x” on your application window. I was surprised they don’t _also_ fire for SIGTERM without effort lol.