Server.json file
Note: The content on this page pertains to Clanforge. If you’re using Multiplay Hosting, refer to the Multiplay Hosting documentation.
To use the Clanforge allocation system, you must enable a method to dynamically specify the file within your server ID directory that has the allocation UUID supplied by your matchmaker along with other configuration variables. This file is the server.json
file.
At a minimum, the server.json
file must include the allocation UUID.
{
"AllocationUUID": "$$allocated_uuid$$"
}
The server.json
file exists within each server instance’s server ID directory relative to the game server binary. It has dynamic information about the game server instance, such as the allocation UUID supplied by your matchmaker, the session authentication key, the connection IP address, and the connection port. Your build can consume variables from the build configuration or the launch parameters. Refer to Configuration variables.
{
"AllocationUUID": "$$allocated_uuid$$",
"SessionAuth": "$$session_auth$$",
"ConnectionIP": "$$ip$$",
"ConnectionPort": "$$port$$"
}
The allocation UUID variable changes with each session, so you’ll need to monitor it for changes. To detect changes within the server.json file, you can 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. Refer to Monitor allocation UUID changes.
Monitor allocation UUID changes
Each game server instance must detect its allocation UUID by monitoring the value of the $$allocation_uuid$$
configuration variable in the server.json file.
Detect an allocation
The $$allocation_uuid$$
variable value changes each time you allocate or deallocate the server instance. Each game server build should monitor the server.json file to detect its allocation status and its allocation UUID.
- When you allocate a server instance, the value updates to the current allocation UUID.
- When you deallocate a server instance, the value updates to contain an empty string.
Note: The server start and server stop actions don't impact the allocation status of the server instance or the allocation UUID.
Detect configuration variable values
Each game server build should monitor the server.json
file for configuration variable changes. For example, when you allocate a server instance, the IP address, port number, and game mode might contain different values from the previous allocation.
The recommended way to monitor changes to the server.json
file on Linux is to use inotify
to detect CLOSE_WRITE
events. For an example of what a CLOSE_WRITE
event looks like, refer to the following inotify
log sample.
MODIFY titanping.json
OPEN titanping.json
OPEN titanping.json
CLOSE_NOWRITE,CLOSE titanping.json
MODIFY titanping.json
CLOSE_WRITE,CLOSE titanping.json
OPEN titanping.json
ACCESS titanping.json
CLOSE_NOWRITE,CLOSE titanping.json