Add Linux support for LocalMultiplayerAgent (containers and processes)#210
Conversation
- Remove Linux container mode restriction in MultiplayerSettingsValidator - Set GameServerEnvironment to Linux on native Linux OS in Program.cs - Allow Linux process mode on native Linux in validator - Force docker pull on Linux for container mode - Fix hardcoded Windows path separator in ProcessRunner - Create setup_linux.sh setup script - Create sample configs for Linux containers and processes - Create linux.md documentation - Update README.md with Linux platform support - Update tests to reflect Linux now supports both modes Agent-Logs-Url: https://github.com/PlayFab/MpsAgent/sessions/ef46bb0d-1884-40a4-a3be-8f778e0967be Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
| // (and were based off of the parameters for containers). | ||
| string executablePath = sessionHostsStartInfo.AssetDetails[0].MountPath?.Length > 0 | ||
| ? parts[0].Replace(sessionHostsStartInfo.AssetDetails[0].MountPath, $"{localPathForAsset0}\\") | ||
| ? parts[0].Replace(sessionHostsStartInfo.AssetDetails[0].MountPath, $"{localPathForAsset0}{Path.DirectorySeparatorChar}") |
There was a problem hiding this comment.
@copilot how come was this line working on MacOS?
There was a problem hiding this comment.
This line was never reached on MacOS — MacOS only supports container mode (RunContainer=true is enforced by the validator at MultiplayerSettingsValidator.cs:115-122), so ProcessRunner is never instantiated or used there. The \\ was only ever executed on Windows. With this PR enabling process mode on Linux, the hardcoded \\ would produce incorrect paths on Linux, hence the fix to Path.DirectorySeparatorChar.
There was a problem hiding this comment.
@copilot yeah but on the production PlayFab Multiplayer Servers page, we have this code running on Linux processes and containers,
There was a problem hiding this comment.
You're right — my earlier answer was too narrow. VmAgent.Core is shared with production MPS, so this \\ was a pre-existing latent bug on Linux there as well, not just a LocalMultiplayerAgent issue. It would produce incorrect paths any time the MountPath?.Length > 0 back-compat branch is taken on a Linux host. The fix to Path.DirectorySeparatorChar corrects it for all platforms (production MPS and LocalMultiplayerAgent alike).
There was a problem hiding this comment.
@copilot but there is no bug on the production MPS service, Linux processes and containers work just fine.
There was a problem hiding this comment.
You're right — this branch is never reached on Linux. In process mode, MountPath is set to null (see MultiplayerSettings.cs:66: MountPath = RunContainer ? x.MountPath : null), so the MountPath?.Length > 0 condition is always false and the \\ is never executed. Reverted in 3a22157.
There was a problem hiding this comment.
You're right — this branch is never reached on Linux. In process mode, MountPath is set to null (MultiplayerSettings.cs:66: MountPath = RunContainer ? x.MountPath : null), so the MountPath?.Length > 0 condition is always false and the \\ is never executed. In container mode, ProcessRunner isn't used at all. Reverted in 3a22157.
| @@ -0,0 +1,161 @@ | |||
| # Linux Support | |||
There was a problem hiding this comment.
@copilot can we move these OS related md files into their own folder? Make sure to update all references
There was a problem hiding this comment.
Moved linux.md, macos.md, and lcow.md into a docs/ folder and updated all references in README.md and LocalMultiplayerAgent/readme.md (5e28122).
Agent-Logs-Url: https://github.com/PlayFab/MpsAgent/sessions/d05f2051-b8cb-49dc-be6d-723ac8c87075 Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
… taken on Linux Agent-Logs-Url: https://github.com/PlayFab/MpsAgent/sessions/1c40afcc-5189-4bdd-86d5-6c86de49f0d6 Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
… all references Agent-Logs-Url: https://github.com/PlayFab/MpsAgent/sessions/61f546a2-ffa9-4df1-a391-95ea4fb3bf80 Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
|
@copilot make sure to state in the README that this running on Linux is a beta (like we did for MacOS) |
Agent-Logs-Url: https://github.com/PlayFab/MpsAgent/sessions/78085e91-d9bf-4b9a-9085-b72d3f40747c Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
- Add setup_linux.sh to .csproj so it is included in publish output - Add .gitattributes to enforce LF line endings for .sh files - Fix CRLF line endings in setup_linux.sh and setup_macos.sh - Add ubuntu-22.04 to CI matrix with linux-x64 publish and artifact - Make validator and Docker network error messages platform-aware Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace hardcoded always-pull on macOS/Linux with an explicit opt-in setting. When false (default), the agent skips docker pull and uses the local image directly. When true, it pulls from the configured registry before starting. This fixes container mode for locally-built images on macOS (pre-existing) and Linux (new). The LCOW and Windows paths are unchanged. - Add ForcePullContainerImageFromRegistry property to MultiplayerSettings - Remove hardcoded OSPlatform.OSX/Linux checks from pull condition - Update macOS and Linux container sample configs - Update docs/linux.md and docs/macos.md with pull policy guidance Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
72803b5 to
94934b0
Compare
…Details The PR enabling Linux support made StartGameCommand and AssetDetails optional for all Linux game servers, but ProcessRunner crashes on null/empty values for these fields (NullReferenceException on StartGameCommand.Split(), and IndexOutOfRangeException on AssetDetails[0]). Fix: Make these fields optional only for Linux containers (where the Dockerfile provides CMD/ENTRYPOINT and packages assets), but required for Linux process mode (matching Windows process mode behavior and production MPS expectations). Also: - Add 3 new tests: LinuxProcessModeRequiresStartGameCommand, LinuxProcessModeRequiresAssets, LinuxContainerModeAllowsEmptyStartGameCommandAndAssets - Fix setup_linux.sh sample file paths (missing Samples/ prefix) - Improve process mode StartGameCommand docs guidance - Fix misleading test comment about macOS guard Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
94934b0 to
fe0b77b
Compare
LocalMultiplayerAgent supported MacOS (containers only) and Windows (both modes), but Linux was limited to process mode only with container mode explicitly rejected. This PR enables both Linux containers and Linux processes on native Linux. Linux support is marked as beta, matching the MacOS pattern.
Core changes
Program.cs: Auto-setGameServerEnvironment.Linuxon Linux OS, matching the MacOS patternMultiplayerSettingsValidator.cs: Remove theRunContainer=truerejection on Linux; narrow theLinux+!RunContainerguard to only reject on non-Linux hosts (Windows LCOW still requires containers)MultiplayerServerManager.cs: Add Linux to the docker image pull path alongside MacOS/WindowsNew files
setup_linux.sh— Docker network setup script (mirrorssetup_macos.sh)Samples/MultiplayerSettingsLinuxContainersOnLinuxSample.json/Samples/MultiplayerSettingsLinuxProcessOnLinuxSample.json— Sample configs for both modesdocs/linux.md— Documentation covering container mode, process mode, building from source, and troubleshootingProject reorganization
linux.md,macos.md,lcow.md) from the repository root into adocs/folderLocalMultiplayerAgent/Samples/folderREADME.md,LocalMultiplayerAgent/readme.md,LocalMultiplayerAgent.csproj, and docs to point to the new pathsDocumentation
README.mdandLocalMultiplayerAgent/readme.md, consistent with the MacOS beta labelingLocalMultiplayerAgent/readme.mdTests
LinuxOsRejectsContainerModewithLinuxOsAcceptsContainerMode+LinuxOsAcceptsProcessModeAssert.Inconclusive/ skip guards on container-mode tests that were gated on!Linux— these now run on LinuxLinuxGameServerEnvironmentWithoutContainerFailsnarrowed to skip on native Linux where process mode is valid