Quick answer: Implement drain on SIGTERM: stop accepting new matches, let active matches finish or migrate, persist state, then exit cleanly before the orchestrator's grace period ends.
Players yanked mid-match every time you deploy are victims of a hard kill. A graceful drain lets running matches end first. Here is how to handle shutdown signals properly.
How to stop it
1. Handle SIGTERM as a drain signal
Catch SIGTERM and flip the server into draining mode. Orchestrators send SIGTERM first and only SIGKILL after a grace period, so use that window to wind down rather than die instantly.
2. Stop new allocations, finish current ones
While draining, mark the server unallocatable so matchmaking stops sending players, but let the current match play out or reach a safe break point before disconnecting anyone.
3. Persist and exit cleanly
Save any durable state and notify clients with a reason before closing connections, then exit 0. Extend the orchestrator's termination grace period if your matches need longer than the default to wind down.
Catching the ones you can't reproduce
The hardest version of this to fix is the one you can't reproduce — it only happens on a player's hardware, OS, driver, or save state, under conditions that simply aren't present on your machine. A report that says “it crashed” or “it froze” gives you nothing to act on, so the bug survives release after release while quietly costing you players.
Automatic error capture closes that gap. Each failure arrives with its full stack trace, the device and OS, the build number, and a breadcrumb trail of what the player did right before it broke, so even a failure you have never seen becomes a specific, reproducible issue. Fold identical failures into one signature ranked by how many players each hits, and your worklist sorts itself worst-first instead of arriving as a stream of vague complaints.
This is where a tool like Bugnet earns its place. Its SDK captures every error automatically with the full stack trace plus device, OS, memory, build, and game-state context, folds duplicates into one grouped issue with an occurrence count, and ties each to the build it first appeared on — so you fix the problem that hurts the most players first and confirm it is gone when its signature disappears from the next release.
Most of the time the fix is small. Seeing the failure clearly is the part that actually costs you.