Skip to content

Add Linux support for LocalMultiplayerAgent (containers and processes)#210

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/add-local-multiplayer-agent-linux-support
Draft

Add Linux support for LocalMultiplayerAgent (containers and processes)#210
Copilot wants to merge 5 commits intomainfrom
copilot/add-local-multiplayer-agent-linux-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

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-set GameServerEnvironment.Linux on Linux OS, matching the MacOS pattern
  • MultiplayerSettingsValidator.cs: Remove the RunContainer=true rejection on Linux; narrow the Linux+!RunContainer guard to only reject on non-Linux hosts (Windows LCOW still requires containers)
  • MultiplayerServerManager.cs: Add Linux to the docker image pull path alongside MacOS/Windows
// Before: Linux was explicitly blocked
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && _settings.RunContainer)
    return false;

// After: only reject Linux process mode on non-Linux hosts
if (Globals.GameServerEnvironment == GameServerEnvironment.Linux && !_settings.RunContainer
    && !RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
    return false;

New files

  • setup_linux.sh — Docker network setup script (mirrors setup_macos.sh)
  • Samples/MultiplayerSettingsLinuxContainersOnLinuxSample.json / Samples/MultiplayerSettingsLinuxProcessOnLinuxSample.json — Sample configs for both modes
  • docs/linux.md — Documentation covering container mode, process mode, building from source, and troubleshooting

Project reorganization

  • Moved OS-related markdown files (linux.md, macos.md, lcow.md) from the repository root into a docs/ folder
  • Moved all MultiplayerSettings sample JSON files into a LocalMultiplayerAgent/Samples/ folder
  • Updated all references in README.md, LocalMultiplayerAgent/readme.md, LocalMultiplayerAgent.csproj, and docs to point to the new paths

Documentation

  • Marked Linux support as (beta) in both README.md and LocalMultiplayerAgent/readme.md, consistent with the MacOS beta labeling
  • Added Linux to the supported platforms list in LocalMultiplayerAgent/readme.md

Tests

  • Replaced LinuxOsRejectsContainerMode with LinuxOsAcceptsContainerMode + LinuxOsAcceptsProcessMode
  • Removed Assert.Inconclusive / skip guards on container-mode tests that were gated on !Linux — these now run on Linux
  • LinuxGameServerEnvironmentWithoutContainerFails narrowed to skip on native Linux where process mode is valid

- 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}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot how come was this line working on MacOS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot yeah but on the production PlayFab Multiplayer Servers page, we have this code running on Linux processes and containers,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot but there is no bug on the production MPS service, Linux processes and containers work just fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot can we move these OS related md files into their own folder? Make sure to update all references

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved linux.md, macos.md, and lcow.md into a docs/ folder and updated all references in README.md and LocalMultiplayerAgent/readme.md (5e28122).

… 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>
@@ -0,0 +1,40 @@
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot let's remove all this MultiplayerSettings sample files on a separate folder. Make sure to update all references

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved all 4 sample JSON files into LocalMultiplayerAgent/Samples/ and updated references in the .csproj, docs, and readme (2cc8e4c).

… 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>
@dgkanatsios
Copy link
Copy Markdown
Contributor

@copilot make sure to state in the README that this running on Linux is a beta (like we did for MacOS)

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot make sure to state in the README that this running on Linux is a beta (like we did for MacOS)

Added "(beta)" to Linux in both README.md and LocalMultiplayerAgent/readme.md, matching the MacOS pattern (c9b6044).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants