Server.json

Note: The content on this page pertains to Game Server Hosting (Multiplay) available on the Unity Dashboard. If you’re using Game Server Hosting (Clanforge), see the Game Server Hosting (Clanforge) documentation.

The server.json file is a file that has variable data, such as the current allocation ID, for each server. It’s automatically generated and populated for each server based on the configuration variables and the server data. It has all the built-in configuration variables and any custom values from your build configuration variables.

The server.json file exists within each server’s server ID directory. By default, it has all the built-in configuration variables, such as the allocation ID supplied by your matchmaker, and the connection port. But you can also add any number of configuration variables to track in the build configuration settings.

Here’s an example of what a server.json file might look like when populated with the configuration variables from a server:

{
	"allocatedID": "$$allocatedUUID$$",
	"serverID": "$$serverID$$",
	"queryType": "$$queryType$$",
	"queryPort": "$$queryPort$$",
	"port": "$$port$$",
}

allocatedID

The allocatedID variable is a special built-in configuration variable that changes each time a server is allocated or unallocated. When a server is allocated, the allocatedID field contains the server’s allocation ID. When a server is unallocated, the allocatedID field contains an empty string.

Note: Other configuration variables keep their value despite the server allocation status.

Here’s an example of a server.json file of an allocated server:

{    
    “allocatedID”: “434af841-586d-4403-939b-db19f77611a6”,    
    “serverID”: “12345”,
    “queryType”: “sqp”,
    “queryPort”: “9010”, 
    “port”: “9000”, 
}

Here’s an example of a server.json file of an unallocated server:

{    
    “allocatedID”: “”,    
    “serverID”: “12345”,
    “queryType”: “sqp”,
    “queryPort”: “9010”, 
    “port”: “9000”, 
}

You can track the allocation ID of a server by monitoring the server.json for changes. To detect changes, set up an event trigger that detects file changes or a process to check the file for changes at a regular interval. It’s best practice to use an event trigger because the interval check causes unnecessary resource usage.

File location

If you're using a container build, the server.json file is already mounted into your container. You can find its location by checking the container's home environment variable.

  • For Linux containers, it's in the $HOME environment variable.
  • For Windows containers, it's in the $HOMEPATH environment variable.