This guide covers what happens inside your game server build when it runs on the PlayFlow platform.

The playflow.json Config File

Every time PlayFlow starts your server, it creates a playflow.json file in the root directory, right next to your server executable. This file contains essential information about the current session, allowing your server to configure itself dynamically. Example playflow.json:
{
  "instance_id": "i-12345abcdef",
  "region": "us-east",
  "custom_data": {
    "map_name": "dust2",
    "game_mode": "competitive"
  }
}
Your server should read this file on startup. For example, you can use the custom_data to tell the server which map to load or what game mode to run.
The SDK provides a helper class to make this easy. Simply call PlayFlowServerConfig.LoadConfig() to get the data.
using PlayFlow;
using UnityEngine;

public class MyGameServer : MonoBehaviour
{
    void Start()
    {
        var config = PlayFlowServerConfig.LoadConfig();
        if (config != null)
        {
            Debug.Log($"Server instance ID is: {config.instance_id}");

            if (config.custom_data.TryGetValue("map_name", out object map))
            {
                Debug.Log($"Loading map: {map}");
                // Your code to load the map...
            }
        }
    }
}

Automatic Server Shutdown

For match-based games, you want the server to shut down after the match is over to save costs. PlayFlow makes this automatic. When your server process exits, PlayFlow detects it and automatically stops the instance. In Unity, this means all you need to do is call Application.Quit() at the end of a match. PlayFlow will handle the rest, ensuring you only pay for the time your server was actually running.

Next Steps

Now that you understand how the server behaves, learn how to control it from your game client or backend.

Programmatic Access

Start, stop, and list servers using the PlayFlow API and Unity SDK.