Monitor for configuration variable changes

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.

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.

Monitor allocation ID changes

Each game server instance must detect its allocation ID by monitoring the value of the allocatedID configuration variable in the server.json file. The allocatedID variable value changes each time you allocate or deallocate the server instance. Game server builds should also monitor the server.json file to detect its allocation status and its allocation ID.

Note: The server start and server stop actions don't impact the allocation status of the server instance or the allocation ID.

Container builds

If you're using a container build, the server.json file is already mounted into your container. You can find the server.json file 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.

Best practices

The recommended way monitor changes to the server.json file depends on the game engine your game is built on.

Game engineBest practice
Unity EngineGame Server SDK for Unity
Unreal EngineGame Server SDK for Unreal
Custom engineinotify

Unity Engine

If your game is built using Unity, the recommended way to monitor for configuration variable changes is to use the Game Server SDK.

Unreal Engine

If your game is built using Unreal Engine, the recommended way to monitor for configuration variable changes is to use the Game Server SDK.

Custom engine

If you’re using a custom game engine, the recommended way is to use inotify to detect CLOSE_WRITE events. For an example of what a CLOSE_WRITE event looks like, see the following inotify log sample.

MODIFY server.json
OPEN server.json
OPEN server.json
CLOSE_NOWRITE,CLOSE server.json
MODIFY server.json
CLOSE_WRITE,CLOSE server.json
OPEN server.json
ACCESS server.json
CLOSE_NOWRITE,CLOSE server.json