tgstation-server 6.19.3
The /tg/station 13 server suite
Loading...
Searching...
No Matches
GeneralConfiguration.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
5using Microsoft.Extensions.Logging;
6using Newtonsoft.Json;
7using Newtonsoft.Json.Converters;
8
14
15using YamlDotNet.Serialization;
16
18{
23 {
27 public const string Section = "General";
28
32 public const ushort DefaultApiPort = 5000;
33
37 public const string DefaultByondZipDownloadTemplate = "https://www.byond.com/download/build/${Major}/${Major}.${Minor}_byond${Linux:_linux}.zip";
38
42 public const string DefaultDiscordSlashCommandName = "tgs";
43
48
52 const uint DefaultInstanceLimit = 10;
53
57 const uint DefaultUserLimit = 100;
58
62 const uint DefaultUserGroupLimit = 25;
63
67 const uint DefaultByondTopicTimeout = 5000;
68
73
78
82 const string DefaultOpenDreamGitUrl = "https://github.com/OpenDreamProject/OpenDream";
83
87 const string DefaultOpenDreamGitTagPrefix = "v";
88
92 public static readonly Version CurrentConfigVersion = Version.Parse(MasterVersionsAttribute.Instance.RawConfigurationVersion);
93
97 public Version? ConfigVersion { get; set; }
98
102 public ushort ApiPort { get; set; }
103
107 public ushort? PrometheusPort { get; set; }
108
112 public string? GitHubAccessToken { get; set; }
113
117 [JsonConverter(typeof(StringEnumConverter))]
118 public SetupWizardMode SetupWizardMode { get; set; }
119
123 public uint ByondTopicTimeout { get; set; } = DefaultByondTopicTimeout;
124
129
134
138 public bool UseBasicWatchdog { get; set; }
139
144
148 public bool HostApiDocumentation { get; set; }
149
153 public bool SkipAddingByondFirewallException { get; set; }
154
158 public uint? DeploymentDirectoryCopyTasksPerCore { get; set; }
159
163 [YamlMember(SerializeAs = typeof(string))]
164 public Uri OpenDreamGitUrl { get; set; } = new Uri(DefaultOpenDreamGitUrl);
165
176
181
185 public bool OpenDreamSuppressInstallOutput { get; set; }
186
190 public List<string>? AdditionalEventScriptsDirectories { get; set; }
191
202
208 public void CheckCompatibility(ILogger logger, IIOManager ioManager)
209 {
210 ArgumentNullException.ThrowIfNull(logger);
211
212 if (ConfigVersion == null)
213 logger.LogCritical(
214 "No `ConfigVersion` specified, your configuration may be out of date! The current version is \"{currentVersion}\"",
217 if (ConfigVersion.Major != CurrentConfigVersion.Major)
218 logger.LogCritical(
219 "Your `ConfigVersion` is majorly out-of-date and may potentially cause issues running the server. Please follow migration instructions from the TGS release notes. The current config version is v{currentConfigVersion}.",
221 else
222 logger.LogWarning("Your `ConfigVersion` is out-of-date. Please follow migration instructions from the TGS release notes.");
223
225 throw new InvalidOperationException(
226 $"{nameof(DeploymentDirectoryCopyTasksPerCore)} must be at least 1!");
227 else if (this.GetCopyDirectoryTaskThrottle() < 1)
228 throw new InvalidOperationException(
229 $"{nameof(DeploymentDirectoryCopyTasksPerCore)} is too large for the CPU core count of {Environment.ProcessorCount} and overflows a 32-bit signed integer. Please lower the value!");
230
231 if (ByondTopicTimeout <= 1000)
232 logger.LogWarning("The timeout for sending BYOND topics is very low ({ms}ms). Topic calls may fail to complete at all!", ByondTopicTimeout);
233
234 if (AdditionalEventScriptsDirectories?.Any(path => !ioManager.IsPathRooted(path)) == true)
235 logger.LogWarning($"Config option \"{nameof(AdditionalEventScriptsDirectories)}\" contains non-rooted paths. These will be evaluated relative to each instances \"Configuration\" directory!");
236 }
237 }
238}
Base class for Response.ServerInformationResponse.
uint UserGroupLimit
The maximum number of user groups allowed.
uint MinimumPasswordLength
Minimum length of database user passwords.
uint InstanceLimit
The maximum number of Instances allowed.
uint? DeploymentDirectoryCopyTasksPerCore
A limit on the amount of tasks used for asynchronous I/O when copying directories during the deployme...
const string Section
The key for the Microsoft.Extensions.Configuration.IConfigurationSection the GeneralConfiguration res...
bool OpenDreamSuppressInstallOutput
If the dotnet output of creating an OpenDream installation should be suppressed. Known to cause issue...
const string DefaultOpenDreamGitTagPrefix
The default value for OpenDreamGitTagPrefix.
GeneralConfiguration()
Initializes a new instance of the GeneralConfiguration class.
Uri OpenDreamGitUrl
Location of a publically accessible OpenDream repository.
static readonly Version CurrentConfigVersion
The current ConfigVersion.
bool HostApiDocumentation
If the swagger documentation and UI should be made avaiable.
const string DefaultByondZipDownloadTemplate
Default vale for ByondZipDownloadTemplate.
bool UseBasicWatchdog
If the Components.Watchdog.BasicWatchdog should be preferred.
const string DefaultOpenDreamGitUrl
The default value for OpenDreamGitUrl.
uint ShutdownTimeoutMinutes
The timeout minutes for gracefully stopping the server.
string OpenDreamGitTagPrefix
The prefix to the OpenDream semver as tags appear in the git repository.
const uint DefaultMinimumPasswordLength
The default value for ServerInformationBase.MinimumPasswordLength.
const ushort DefaultApiPort
The default value of ApiPort.
uint RestartTimeoutMinutes
The timeout minutes for restarting the server.
ushort? PrometheusPort
The port Prometheus metrics are published on, if any.
string DiscordSlashCommandName
The Discord slash command name for TGS chat commands.
uint ByondTopicTimeout
The timeout in milliseconds for sending and receiving topics to/from DreamDaemon. Note that a single ...
const uint DefaultRestartTimeoutMinutes
The default value for RestartTimeoutMinutes.
void CheckCompatibility(ILogger logger, IIOManager ioManager)
Validates the current ConfigVersion's compatibility and provides migration instructions.
const uint DefaultUserLimit
The default value for ServerInformationBase.UserLimit.
Version? ConfigVersion
The Version the file says it is.
string? GitHubAccessToken
A classic GitHub personal access token to use for bypassing rate limits on requests....
const uint DefaultByondTopicTimeout
The default value for ByondTopicTimeout.
const uint DefaultInstanceLimit
The default value for ServerInformationBase.InstanceLimit.
const uint DefaultUserGroupLimit
The default value for ServerInformationBase.UserGroupLimit.
const uint DefaultShutdownTimeoutMinutes
The default value for ShutdownTimeoutMinutes.
List< string >? AdditionalEventScriptsDirectories
List of directories that have their contents merged with instance EventScripts directories when execu...
const string DefaultDiscordSlashCommandName
The default value for DiscordSlashCommandName.
string ByondZipDownloadTemplate
The formatter used to download official byond zip files for a given version.
bool SkipAddingByondFirewallException
If the netsh.exe execution to exempt DreamDaemon from Windows firewall should be skipped.
Attribute for bringing in the master versions list from MSBuild that aren't embedded into assemblies ...
string RawConfigurationVersion
The Version string of the Configuration version built.
static MasterVersionsAttribute Instance
Return the Assembly's instance of the MasterVersionsAttribute.
Interface for using filesystems.
Definition IIOManager.cs:14
bool IsPathRooted(string path)
Check if a given path is at the root level of the filesystem.
SetupWizardMode
Determines if the SetupWizard will run.