Configuration¶
Example configuration:
[core]
provisioner = linode
# Include trailing slashes for these paths
local_server_dir = ./gameserver/
remote_server_dir = ~/gameserver/
remote_server_user = root
server_bootstrap = bootstrap.sh
server_entry_point = start.sh
server_graceful_stop = stop.sh
[linode]
access_token = TOKEN
public_key_path = ~/.ssh/id_ed25519.pub
linode_type = g6-standard-4
linode_image = linode/debian12
linode_label = mc-server
linode_region = us-west
[discord]
token = TOKEN
command_prefix = !
lease_increment_minutes = 60
lease_warning_threshold_minutes = 30
lease_max_remaining_minutes = 120
Some configuration values can be overriden at runtime by an environment variable.
The classes below detail each available configuration option, the namespace they exist under, their default values and their environment variable name, if applicable.
Core¶
Namespace: ‘[core]’
- class smpsave.core.config.CoreConfig(provisioner: str, local_server_dir: str, remote_server_dir: str, remote_server_user: str = 'root', server_bootstrap: str = 'bootstrap.sh', server_entry_point: str = 'start.sh', server_graceful_stop: str = 'stop.sh')¶
CoreConfig contains central configuration values for the application.
- local_server_dir: str¶
Path to the local directory containing the game server files. This must also be the root directory for the server lifecycle scripts.
- provisioner: str¶
User’s choice of provisioner backend.
- remote_server_dir: str¶
The directory in the game server’s filesystem that should
- remote_server_user: str = 'root'¶
Username to use when connecting to the game server.
- server_bootstrap: str = 'bootstrap.sh'¶
Path to the ‘bootstrap’ server lifecycle script. Must be relative to local_server_dir.
- server_entry_point: str = 'start.sh'¶
Path to the ‘start’ server lifecycle script. Must be relative to local_server_dir.
- server_graceful_stop: str = 'stop.sh'¶
Path to the ‘stop’ server lifecycle script. Must be relative to local_server_dir.
Linode¶
Namespace: ‘[linode]’
- class smpsave.provisioning.LinodeProvisionerConfig(access_token: str, linode_type: str, linode_image: str, linode_label: str, linode_region: str, public_key_path: str)¶
- access_token: str¶
Linode access token. Must provide read/write access to linodes. May be overriden at runtime by the LINODE_TOKEN environment variable.
- linode_image: str¶
String identifying the image to use for the provisioned linode. Consult linode’s documentation for a complete list of options.
- linode_label: str¶
A unique label to identify the linode provisioned by this application.
- linode_region: str¶
The linode region to deploy the game server to. Consult Linode’s documentation for a complete list of options.
- linode_type: str¶
String identifying the linode type to provision. Consult linode’s API documentation for a complete list of options.
- populate_from_env()¶
Abstract: Will be called in postinit. Used to map environment variable overrides to their values.
- public_key_path: str¶
Path to the public key on this system which the provisioned linode should authorize for future incoming SSH connections.
Discord¶
Namespace: ‘[discord]’
- class smpsave.discordbot.config.DiscordBotConfig(token: str, allowed_role: int, command_prefix: str = '!', lease_increment_minutes: int = 30, lease_warning_threshold_minutes: int = 30, lease_max_remaining_minutes: int = 120)¶
- allowed_role: int¶
Snowflake ID of the role required to use server management commands.
- command_prefix: str = '!'¶
Prefix symbol used for commands (i.e., in !start, ‘~’ is the prefix)
- lease_increment_minutes: int = 30¶
Time in minutes to extend the lease by when the extend command is used.
- lease_max_remaining_minutes: int = 120¶
Maximum duration of a server lease in minutes. The lease may not be extended beyond this time.
- lease_warning_threshold_minutes: int = 30¶
Remaning time threshold, in minutes, after which to provide a warning message that the server will shut off soon.
- populate_from_env()¶
Abstract: Will be called in postinit. Used to map environment variable overrides to their values.
- token: str¶
Discord oauth2 token. May be overridden at runtime by the DISCORD_TOKEN environment variable.