Class ServerPackageSpec

Namespace
Unity.Multiplayer.Core

The provider-neutral server package: what every host gets, whichever IHostingProfile it is built for. A self-contained Linux x86_64 Dedicated Server build of the game plus:

  • server.json: the settings, overridden by the environment and command line (ServerStartup);
  • start.sh: starts the server with the package's settings and forwards its arguments (-port -maxPlayers -name -password); it execs, so SIGTERM and SIGINT reach the server, which shuts down cleanly;
  • server-package.json: the manifest a deploy tool reads (profile, executable, declared ports, health path);
  • Logs/ and Saves/: log files, and the game's persistent data;
  • the profile's own files (a Dockerfile, a compose file, notes).
public sealed class ServerPackageSpec
Inheritance
ServerPackageSpec
Inherited Members

Fields

ExecutableExtension

The extension Unity gives a Linux x86_64 executable.

public const string ExecutableExtension = ".x86_64"

Field Value

string

ManifestFileName

The manifest's name.

public const string ManifestFileName = "server-package.json"

Field Value

string

ManifestFormat

The manifest format version written.

public const int ManifestFormat = 1

Field Value

int

StartScriptName

The start script's name.

public const string StartScriptName = "start.sh"

Field Value

string

UnityPlayerLibrary

The Unity engine library every Linux player ships beside its executable.

public const string UnityPlayerLibrary = "UnityPlayer.so"

Field Value

string

Properties

Config

The settings written to server.json; the topology is always Server.

public NetConfig Config { get; }

Property Value

NetConfig

DataFolderName

Unity's data folder beside the executable: its name without the extension, plus _Data.

public string DataFolderName { get; }

Property Value

string

ExecutableName

The server executable's file name, such as MyGame.x86_64.

public string ExecutableName { get; }

Property Value

string

ExtraArgs

More arguments start.sh always passes, before the ones it is given.

public List<string> ExtraArgs { get; }

Property Value

List<string>

Ports

The ports the server listens on: the game port (UDP, or TCP for WebSocket) and the health port when on.

public IReadOnlyList<DeclaredPort> Ports { get; }

Property Value

IReadOnlyList<DeclaredPort>

Profile

The profile the package is built for.

public IHostingProfile Profile { get; }

Property Value

IHostingProfile

Settings

The package settings written to server.json.

public ServerSettings Settings { get; }

Property Value

ServerSettings

Methods

ComposeFiles()

The files the package holds besides Unity's build output, in a fixed order: server.json, start.sh, the manifest, Logs/, Saves/, then the profile's files.

public IReadOnlyList<ServerPackageFile> ComposeFiles()

Returns

IReadOnlyList<ServerPackageFile>

Exceptions

InvalidOperationException

The profile adds a file the package already has.

ComposeManifest()

The manifest JSON a deploy tool reads.

public string ComposeManifest()

Returns

string

ComposeStartScript()

The POSIX shell start script.

public string ComposeStartScript()

Returns

string

ExpectedLayout()

Every path the finished package must contain: Unity's executable, data folder and engine library, then ComposeFiles()'. A build is complete when each exists.

public IReadOnlyList<ServerPackageFile> ExpectedLayout()

Returns

IReadOnlyList<ServerPackageFile>

For(IHostingProfile, string, NetConfig, ServerSettings)

The spec profile builds: copies of config and settings (defaults when null), switched to a dedicated server, then adjusted by Configure(ServerPackageSpec).

public static ServerPackageSpec For(IHostingProfile profile, string executableName, NetConfig config = null, ServerSettings settings = null)

Parameters

profile IHostingProfile
executableName string
config NetConfig
settings ServerSettings

Returns

ServerPackageSpec

Exceptions

ArgumentNullException

profile is null.

ArgumentException

executableName is not a safe file name.

IsInsidePackage(string)

True when directory is a relative path that stays inside the package folder.

public static bool IsInsidePackage(string directory)

Parameters

directory string

Returns

bool

IsSafeFileName(string)

True for a non-empty file name of letters, digits, '.', '_' and '-' that is not '.' or '..'.

public static bool IsSafeFileName(string name)

Parameters

name string

Returns

bool

LaunchArguments()

The arguments start.sh starts the executable with, executable first; its own arguments follow.

public IReadOnlyList<string> LaunchArguments()

Returns

IReadOnlyList<string>

ShellQuote(string)

Quotes value for a POSIX shell when it needs it.

public static string ShellQuote(string value)

Parameters

value string

Returns

string

Validate()

Lists every problem with the spec; an empty list means it can be built.

public IReadOnlyList<string> Validate()

Returns

IReadOnlyList<string>