tgstation-server 6.19.0
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
43
47 const uint DefaultInstanceLimit = 10;
48
52 const uint DefaultUserLimit = 100;
53
57 const uint DefaultUserGroupLimit = 25;
58
62 const uint DefaultByondTopicTimeout = 5000;
63
68
73
77 const string DefaultOpenDreamGitUrl = "https://github.com/OpenDreamProject/OpenDream";
78
82 const string DefaultOpenDreamGitTagPrefix = "v";
83
87 public static readonly Version CurrentConfigVersion = Version.Parse(MasterVersionsAttribute.Instance.RawConfigurationVersion);
88
92 public Version? ConfigVersion { get; set; }
93
97 public ushort ApiPort { get; set; }
98
102 public ushort? PrometheusPort { get; set; }
103
107 public string? GitHubAccessToken { get; set; }
108
112 [JsonConverter(typeof(StringEnumConverter))]
113 public SetupWizardMode SetupWizardMode { get; set; }
114
118 public uint ByondTopicTimeout { get; set; } = DefaultByondTopicTimeout;
119
124
129
133 public bool UseBasicWatchdog { get; set; }
134
138 public bool HostApiDocumentation { get; set; }
139
143 public bool SkipAddingByondFirewallException { get; set; }
144
148 public uint? DeploymentDirectoryCopyTasksPerCore { get; set; }
149
153 [YamlMember(SerializeAs = typeof(string))]
154 public Uri OpenDreamGitUrl { get; set; } = new Uri(DefaultOpenDreamGitUrl);
155
166
171
175 public bool OpenDreamSuppressInstallOutput { get; set; }
176
180 public List<string>? AdditionalEventScriptsDirectories { get; set; }
181
192
198 public void CheckCompatibility(ILogger logger, IIOManager ioManager)
199 {
200 ArgumentNullException.ThrowIfNull(logger);
201
202 if (ConfigVersion == null)
203 logger.LogCritical(
204 "No `ConfigVersion` specified, your configuration may be out of date! The current version is \"{currentVersion}\"",
207 if (ConfigVersion.Major != CurrentConfigVersion.Major)
208 logger.LogCritical(
209 "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}.",
211 else
212 logger.LogWarning("Your `ConfigVersion` is out-of-date. Please follow migration instructions from the TGS release notes.");
213
215 throw new InvalidOperationException(
216 $"{nameof(DeploymentDirectoryCopyTasksPerCore)} must be at least 1!");
217 else if (this.GetCopyDirectoryTaskThrottle() < 1)
218 throw new InvalidOperationException(
219 $"{nameof(DeploymentDirectoryCopyTasksPerCore)} is too large for the CPU core count of {Environment.ProcessorCount} and overflows a 32-bit signed integer. Please lower the value!");
220
221 if (ByondTopicTimeout <= 1000)
222 logger.LogWarning("The timeout for sending BYOND topics is very low ({ms}ms). Topic calls may fail to complete at all!", ByondTopicTimeout);
223
224 if (AdditionalEventScriptsDirectories?.Any(path => !ioManager.IsPathRooted(path)) == true)
225 logger.LogWarning($"Config option \"{nameof(AdditionalEventScriptsDirectories)}\" contains non-rooted paths. These will be evaluated relative to each instances \"Configuration\" directory!");
226 }
227 }
228}
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.
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...
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.