Digital Ocean deployment
It is highly recommended that you test the kit locally on your machine first, before trying to deploy it to a remote server. It is also highly recommended that you have a basic knowledge of server administration before attempting to deploy the kit to a remote server.
As a user of the kit, you are solely responsible for the administration and maintenance costs of your dedicated server. This assumes a knowledge of what a dedicated server is and how to set up one on your end. We only provide the backend code for you to build your own platform upon.
We do not provide support for matters not strictly related to the kit, such as writing your game's multiplayer logic or setting up/deploying the kit on your dedicated server. Your server is your responsibility, and we do not have any control nor responsibility over it.
In this section, we include a step-by-step tutorial on how to deploy the kit to a remote server on Digital Ocean. This serves two purposes: to demonstrate the kit has been successfully deployed to an actual, remote server and to serve as a helpful reference for your own deployments. There is an infinite variety of service providers available on the market and we could never possibly cover them all, but the main steps should be similar across all of them.
Creating a new droplet
After creating your account on Digital Ocean, go to the Droplets section and create a new droplet (a droplet is the term used by Digital Ocean to refer to one of their remote servers). Feel free to use the configuration most suited to your needs, but please note this tutorial assumes a Ubuntu 20.04 (LTS) x64 server.
Installing the required dependencies
Once your droplet is created, you can log into it via SSH with the following command:
Once connected to the droplet, you need to install Go and MySQL. You can install Go with the following command:
snap install go --classic
And MySQL with the following command:
sudo apt install mysql-server
We highly recommend studying the official guide on MySQL from Digital Ocean available here, as your setup can range from very simple for a quick test to more complex and secure for production purposes.
Creating the MySQL database
With MySQL properly configured, you can now send the database creation script via the following command:
scp create_database.sql root@YOUR_IP_ADDRESS:~/create_database.sql
You can run the script by entering into the MySQL console in your droplet and typing the following command:
mysql> source create_database.sql
Setting up and launching the Go server
With the MySQL database properly created, you can now send the Go server and the Linux game server build files via the following commands:
scp dsk.zip root@YOUR_IP_ADDRESS:~/dsk.zip
scp ServerBuild.zip root@YOUR_IP_ADDRESS:~/ServerBuild.zip
The dsk.zip file contains the files of the Go server (included in the kit), while the ServerBuild.zip contains the Linux build of the game server (that you need to generate from Unity; see the appendix at the bottom of this guide). Of course, you can call these compressed files anything you want; these names are just examples.
You can unzip these files with the unzip command.
Before launching the Go server, you will need to tweak the conf.json file so that it contains valid information for your server. Specifically, you want to make sure the following properties are correct:
Please make sure to use the absolute path to your game server binary here (including the actual binary name). A common reason for the game servers failing in deployment is having an incorrect path here. If the Go server is not able to find the path of the game server binary, no game server instances will be spawned at runtime. A possible example of this property would be:
Which would point to the GameServer.x64 binary located in the root/GameServer folder of your server.
Now, you can finally build the Go server via the following command:
And launch it in the background via the following command:
Configuring the game client on the Unity side
With the remote server properly configured, you can now test the game client from within the Unity editor. You will need to create a new configuration that points to your droplet's IP address instead of localhost. Make sure to update the Client object in the client's Home and Lobby scenes so that they point to this configuration.
Appendix: Generating the Linux game server build
You can generate the game server build that you will upload to your droplet either manually via the Build Settings window in Unity, or programmatically via the included editor script. The most important thing to note is that the build needs to contain the GameServer and Game scenes (with the GameServer scene being the first one).
Make sure you give the execution permission to the game server binary via the chmod +x command. Without it, the Go server will not be able to spawn game server instances as players request new games.
Appendix: Making sure the appropriate ports of your server are open and accessible from the outside
A common issue when deploying to a remote server is not properly configuring the firewall so that the ports used by the kit are open and accessible from the outside. We highly recommend studying the official guide from Digital Ocean available here.
Specifically for the kit and by default, port 8000 (TCP) is used for the Go server and ports 9000 and forward (UDP with the default transport for Mirror) are used for the spawned game server instances. So you want to make sure these ports are open and accessible in your droplet.
I cannot connect to the Go server
Please try adding the http:// prefix to your IP addresses set on on the GameServer and Client objects. This seems to be needed on some systems.
My game server instances are not being spawned
When a player creates a new game, the Go server will spawn a new instance of your game server binary. You can check a game server binary is indeed running via the ps aux command. The most common reasons for the game server binary not being spawned are:
The "game_server_bin_path" property of your configuration file does not point to the actual location of the game binary on your server.
Your game server binary does not have the execution permission.
Please refer to the previous sections to learn how to properly configure everything and avoid these issues.