Upload the dedicated server to AMS - Game server integration - (Unity module)
Package Linux dedicated server
You can only upload Linux game server build to AMS. In this section, you learn how to package your game server as Linux build.
Open Byte Wars in Unity Editor and then go to File > Build Settings.
On the new window, select Dedicated Server for the Platform, and choose Linux as the Target Platform. Also, enable the Development Build to display the logs on the server build.
Next, click on the Build button.
On a new pop-up window, name the server build as ByteWars.x86_64. Then, hit enter on your keyboard to start the build process and wait until it finished.
Upload server image to AMS
In this tutorial section, you learn how to upload your game server Linux build to AMS as server image.
Log in to the Admin Portal and go to your game namespace dashboard.
Go to Multiplayer Server Configuration > Download Resource.
Download the AMS Command Line Interface (CLI) For Windows (amd64). The ams.exe file should be downloaded.
Upload the Linux dedicated server using the AMS CLI. Run ams.exe using a Windows PowerShell with the command below. Use the client ID and client secret from your ByteWars-AMS IAM client you created in the previous section to replace
<AMSCLI_ClientID>
and<AMSCLI_ClientSecret>
..\ams.exe upload -H <AMS_HostURL> -c <AMSCLI_ClientID> -s <AMSCLI_ClientSecret> -n <DSImageName> -p <DSAbsoluteLocalPath> -e ByteWars.x86_64
infoHere are the details of the AMS CLI command to upload your dedicated server.
-H
: the AMS host URL depending on where you run your AGS namespace. For AGS Private Cloud, your host URL is<studio_name>.accelbyte.io
. For AGS Shared Cloud, your host URL isprod.gamingservices.accelbyte.io
.-c
: the IAM client ID used to authenticate. Set it to the IAM client ID from the AMS CLI IAM client you created.-s
: the IAM client secret used to authenticate. Set it to the IAM client secret from the AMS CLI IAM client you created.-n
: the name of the dedicated server image after the upload process completes. It can be anything, but make it meaningful. For example,1.4.0-unity-bytewars
, which indicates the server version.-p
: the local path to the server directory to upload. For example, you can use an absolute path likeC:/Documents/ByteWars/LinuxServer
or a relative path like../ByteWars/LinuxServer
.-e
: the dedicated server executable within the server directory. In this case, the executable is theByteWars.x86_64
file.
Once the uploading process finishes, you can see your new dedicated server image listed in the Admin Portal. You can also check it by going to Multiplayer Server Configuration > Server Images.
Create AMS fleet
You can use your uploaded server image to create instances of dedicated server managed by the AMS fleet. The AMS fleet function to scale virtual machines and manage dedicated servers that are hosted within those virtual machines based on regional configurations. In this section, you learn how to create a fleet for your game server.
Log in to the Admin Portal and go to your game namespace dashboard.
Go to Multiplayer Server Configuration > Fleet Manager.
In the Region List section, toggle the regions where you want your dedicated servers to be deployed. In this tutorial, ap-southeast-1 and us-east-2 are enabled.
Click Create Fleet > Create New to create a new fleet.
On the new Fleet & Image tab, fill in fleet name and select the server image that you just uploaded. The fleet name can be anything, but to make it simpler, you can use the same name as the server image name. Once done, click the Next button.
On the Deployment Profile tab, leave Timeout and Port Configuration configs as default. For Command Line config, enter the default command below, which configures the dedicated server so it can be managed by AMS. Once done, click Next.
-dsid ${dsid} -port ${default_port}
On the DS Host & Region tab, you can select a Virtual Machine (VM) instance type based on your need. For this tutorial, let's use a small instance. Select the ttx1.s for the Host Instance and set the Dedicated Servers number to 2. This configuration tells the fleet to spawn two dedicated servers on the selected VM instance.
Still in the DS Host & Region tab, go to the Regional Configuration section. Then, enable your desired regions, in this example we use ap-southeast-1 and us-east-2. For this tutorial, set the Min Servers to 0, Max Servers to 2, and the Buffer Value to 1.
info- Min Servers: The minimum number of servers that the deployment needs to maintain, regardless of whether the servers are in the "Ready" (warmed buffer) state or "In Session" (serving a game session) state.
- Max Servers: The maximum number of servers that the region can maintain. This value is useful as a limiter to make sure the cost of game servers will not go over budget.
- Buffer Value: The buffer value tells the fleet the number of servers to maintain as warmed buffers.
On the Log & Artifacts Sampling tab, you want the dedicated server able to generate logs. To do this, enable the Enable Log Sampling option and set the samples to 100%. This config lets the dedicated server log every single event. Once done, click the Next button.
On the Summary tab, you can review your fleet configurations. Then, click the Create button to create the new fleet.
Your fleet is created and available in the fleet list. Open the fleet details by clicking on the fleet name.
If your fleet is not activated, locate the Fleet Status toggle on the top-left corner, below your fleet name. Make sure to toggle it to Active.
On the fleet details page, locate the Dedicated Server List section. There, you can see your dedicated servers and their statuses.
infoA new fleet usually take around around 3 minutes to get the dedicated server up and running before you can see them in the list. Below are the states of the dedicated servers on a fleet.
- Creating: the dedicated server is currently initializing (not yet calling the send ready message to the AMS watchdog).
- Ready: the dedicated server has sent a ready signal to AMS and is ready to go.
- Claiming: the fleet manager is currently claiming the dedicated server to a session using a claim key.
- Claimed: the dedicated server is already bound to a game session and the game is currently in progress.
- Removed: the dedicated server is removed from the fleet.
Create claim keys for the fleet
In this section, you learn how to create claim keys to claim your dedicated servers from your AMS fleet. These claim keys then can be used by your backend service to specifically claim dedicated servers from AMS fleet that has the same claim key associated. This is also handy if you have multiple AMS fleet active on your namespace.
Log in to the Admin Portal and go to your game namespace dashboard.
Go to Multiplayer Server Configuration > Fleet Manager and click on the name of your fleet you created.
Under the Fleet Information section, click the Add More button. For this tutorial, you need to input a new claim key named unity-ds-ams.
Now, you can use unity-ds-ams claim key on your backend service to claim your dedicated servers for your game clients.