Capture and surface game server exit codes in LocalMultiplayerAgent#209
Draft
Capture and surface game server exit codes in LocalMultiplayerAgent#209
Conversation
- IProcessWrapper.WaitForProcessExit now returns int (exit code) - ProcessWrapper tracks started processes in ConcurrentDictionary for reliable exit code capture even when process crashes early - ISessionHostRunner.WaitOnServerExit now returns Task<int> - ProcessRunner and DockerContainerEngine return exit codes - MultiplayerServerManager logs and prints the exit code to console Agent-Logs-Url: https://github.com/PlayFab/MpsAgent/sessions/99f02fa0-80b5-470b-afbc-8b85cf45d9fa Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
dgkanatsios
April 8, 2026 08:03
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Game server exit codes were silently discarded. For containers, the code logged the exit code but never returned it. For processes, exit codes were never captured at all. This made it impossible to diagnose crashes or non-zero exits from the game server.
Interface changes
IProcessWrapper.WaitForProcessExit:void→intISessionHostRunner.WaitOnServerExit:Task→Task<int>BaseSessionHostRunnerabstract signature updated accordinglyProcessWrapper: retain Process references to avoid
GetProcessByIdpitfallsProcess.GetProcessById(pid)throwsArgumentExceptionif the process has already exited, and is subject to PID reuse races. Both make exit code retrieval unreliable for short-lived or crashing servers.ProcessWrappernow tracks startedProcessobjects in aConcurrentDictionaryand retrieves them by ID inWaitForProcessExit, falling back toGetProcessByIdonly for externally-started processes.Runner implementations
ProcessRunner— returns and logs exit code fromProcessWrapperDockerContainerEngine— returnsContainerWaitResponse.StatusCode(was already captured, just discarded)MultiplayerServerManager
Captures the exit code and writes it to both logger and console: