Dedicated Server for Unity using Mirror and Lightsail

1.5k Views Asked by At

I am running into issues when attempting to run the built Server.x86_64 when running it on lightsail. My output when running './Server.x86_64' in the server directory is:

[UnityMemory] Configuration Parameters - Can be set up in boot.config
    "memorysetup-bucket-allocator-granularity=16"
    "memorysetup-bucket-allocator-bucket-count=8"
    "memorysetup-bucket-allocator-block-size=4194304"
    "memorysetup-bucket-allocator-block-count=1"
    "memorysetup-main-allocator-block-size=16777216"
    "memorysetup-thread-allocator-block-size=16777216"
    "memorysetup-gfx-main-allocator-block-size=16777216"
    "memorysetup-gfx-thread-allocator-block-size=16777216"
    "memorysetup-cache-allocator-block-size=4194304"
    "memorysetup-typetree-allocator-block-size=2097152"
    "memorysetup-profiler-bucket-allocator-granularity=16"
    "memorysetup-profiler-bucket-allocator-bucket-count=8"
    "memorysetup-profiler-bucket-allocator-block-size=4194304"
    "memorysetup-profiler-bucket-allocator-block-count=1"
    "memorysetup-profiler-allocator-block-size=16777216"
    "memorysetup-profiler-editor-allocator-block-size=1048576"
    "memorysetup-temp-allocator-size-main=4194304"
    "memorysetup-job-temp-allocator-block-size=2097152"
    "memorysetup-job-temp-allocator-block-size-background=1048576"
    "memorysetup-job-temp-allocator-reduction-small-platforms=262144"
    "memorysetup-temp-allocator-size-background-worker=32768"
    "memorysetup-temp-allocator-size-job-worker=262144"
    "memorysetup-temp-allocator-size-preload-manager=262144"
    "memorysetup-temp-allocator-size-nav-mesh-worker=65536"
    "memorysetup-temp-allocator-size-audio-worker=65536"
    "memorysetup-temp-allocator-size-cloud-worker=32768"
    "memorysetup-temp-allocator-size-gfx=262144"

I don't get any message saying the server started or anything. I am using a KCP transport through Mirror and put up a basic Lightsail Linux Server. I built the dedicated server code using the following:

[MenuItem("Build/Build Server (Linux)")]
public static void BuildLinuxServer()
{
    BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    buildPlayerOptions.scenes = new[] { "Assets/Scenes/Main.unity" };
    buildPlayerOptions.locationPathName = "Builds/Linux/Server/Server.x86_64";
    buildPlayerOptions.target = BuildTarget.StandaloneLinux64;
    buildPlayerOptions.options = BuildOptions.CompressWithLz4HC | BuildOptions.EnableHeadlessMode;

    Console.WriteLine("Building Server (Linux)...");
    BuildPipeline.BuildPlayer(buildPlayerOptions);
    Console.WriteLine("Built Server (Linux).");
}

Let me know if you need any other info. For reference, I was following a tutorial on Youtube which may be helpful to know.

1

There are 1 best solutions below

1
Wp3Dev On

For anyone that has troubles with this I found the answer here. Basically, Unity 2021 changed the way they handle headless servers. So, if you are using a script (like I did from the Shrine tutorial), you should change this:

buildPlayerOptions.options = BuildOptions.CompressWithLz4HC | BuildOptions.EnableHeadlessMode;

to this:

buildPlayerOptions.subtarget = (int)(StandaloneBuildSubtarget.Server);

This is in BuildScript. Also make sure to open 7777 port for UDP if using KCP transport.