Environment
The BlueDragonMC/Server project loads several environment configuration options at startup that influence its interaction with other services.
Development and Production Modes
The server is determined to be in “Dev” or “Prod” modes by looking at the BLUEDRAGON_ENV_TYPE
environment variable. If it’s set to “DEV”, the server is assumed to be in development mode, and if not, the server will be set to production mode.
If the BLUEDRAGON_ENV_TYPE
is not set, the fallback is to check for a directory called /server
at the file system root. If it exists, then production mode is used; if not, development mode.
Environment Variable Reference
Environment variable | Defaults | Description |
---|---|---|
BLUEDRAGON_QUEUE_TYPE | Dev: TEST Prod: IPC | Use “IPC” to connect to Puffin for queueing, or “TEST” for a fully-local/single-instance queue |
BLUEDRAGON_MONGO_CONNECTION_STRING | Dev: mongodb://localhost:27017 Prod: mongodb://mongo:27017 | The hostname that resolves to a MongoDB instance |
BLUEDRAGON_PUFFIN_HOSTNAME | Dev: localhost Prod: puffin | The hostname that resolves to a Puffin instance |
BLUEDRAGON_PUFFIN_PORT | 50051 | The port of Puffin’s gRPC server. |
BLUEDRAGON_LUCKPERMS_HOSTNAME | Dev: http://localhost:8080 Prod: http://luckperms:8080 | The hostname that resolves to a standalone LuckPerms instance |
BLUEDRAGON_DEFAULT_GAME | lobby | The game to automatically create on startup. Typically used to immediately initialize a lobby on each game server. |
BLUEDRAGON_AGONES_DISABLED | Not set | If this environment variable is present with any value, Agones integration will be disabled. |
PUFFIN_VELOCITY_SECRET | Not set | The Velocity modern forwarding secret. If not present, Velocity forwarding is disabled. |
BLUEDRAGON_GRPC_SERVER_PORT | 50051 | The port to listen on for gRPC requests. |
View ConfiguredEnvironment source code for more details about server environment configuration.
Other Environment Information
- The
Environment
class also stores version information handled by the Blossom Gradle plugin. SeeGitVersionInfo
for more details. - The environment contains a list of all registered games obtained from the
GameLoader
.
Server Naming
Every game server must have a unique name to interact properly with other services. The default ConfiguredEnvironment
goes through the following process for determining a server’s name:
- If the
HOSTNAME
environment variable is set, its value will be used as the server name. - If the server is in development mode or Agones integration is disabled, a random string will be created and used.
- If the server is in production mode and Agones integration is enabled, a gRPC request will be sent to get the server name from the Agones gRPC API.
The result is then cached for future lookups.