tgstation-server 6.12.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.IO;
4using System.Linq;
5
6using Microsoft.Extensions.Logging;
7using Newtonsoft.Json;
8using Newtonsoft.Json.Converters;
9
14
15using YamlDotNet.Serialization;
16
18{
23 {
27 public const string Section = "General";
28
32 public const ushort DefaultApiPort = 5000;
33
38
42 const uint DefaultInstanceLimit = 10;
43
47 const uint DefaultUserLimit = 100;
48
52 const uint DefaultUserGroupLimit = 25;
53
57 const uint DefaultByondTopicTimeout = 5000;
58
63
68
72 const string DefaultOpenDreamGitUrl = "https://github.com/OpenDreamProject/OpenDream";
73
77 const string DefaultOpenDreamGitTagPrefix = "v";
78
82 public static readonly Version CurrentConfigVersion = Version.Parse(MasterVersionsAttribute.Instance.RawConfigurationVersion);
83
87 public Version? ConfigVersion { get; set; }
88
92 public ushort ApiPort { get; set; }
93
97 public string? GitHubAccessToken { get; set; }
98
102 [JsonConverter(typeof(StringEnumConverter))]
103 public SetupWizardMode SetupWizardMode { get; set; }
104
108 public uint ByondTopicTimeout { get; set; } = DefaultByondTopicTimeout;
109
114
119
123 public bool UseBasicWatchdog { get; set; }
124
128 public bool HostApiDocumentation { get; set; }
129
133 public bool SkipAddingByondFirewallException { get; set; }
134
138 public uint? DeploymentDirectoryCopyTasksPerCore { get; set; }
139
143 [YamlMember(SerializeAs = typeof(string))]
144 public Uri OpenDreamGitUrl { get; set; } = new Uri(DefaultOpenDreamGitUrl);
145
150
154 public bool OpenDreamSuppressInstallOutput { get; set; }
155
159 public List<string>? AdditionalEventScriptsDirectories { get; set; }
160
171
176 public void CheckCompatibility(ILogger logger)
177 {
178 ArgumentNullException.ThrowIfNull(logger);
179
180 if (ConfigVersion == null)
181 logger.LogCritical(
182 "No `ConfigVersion` specified, your configuration may be out of date! The current version is \"{currentVersion}\"",
185 if (ConfigVersion.Major != CurrentConfigVersion.Major)
186 logger.LogCritical(
187 "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}.",
189 else
190 logger.LogWarning("Your `ConfigVersion` is out-of-date. Please follow migration instructions from the TGS release notes.");
191
193 throw new InvalidOperationException(
194 $"{nameof(DeploymentDirectoryCopyTasksPerCore)} must be at least 1!");
195 else if (this.GetCopyDirectoryTaskThrottle() < 1)
196 throw new InvalidOperationException(
197 $"{nameof(DeploymentDirectoryCopyTasksPerCore)} is too large for the CPU core count of {Environment.ProcessorCount} and overflows a 32-bit signed integer. Please lower the value!");
198
199 if (ByondTopicTimeout <= 1000)
200 logger.LogWarning("The timeout for sending BYOND topics is very low ({ms}ms). Topic calls may fail to complete at all!", ByondTopicTimeout);
201
202 if (AdditionalEventScriptsDirectories?.Any(path => !Path.IsPathRooted(path)) == true)
203 logger.LogWarning($"Config option \"{nameof(AdditionalEventScriptsDirectories)}\" contains non-rooted paths. These will be evaluated relative to each instances \"Configuration\" directory!");
204 }
205 }
206}
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.
void CheckCompatibility(ILogger logger)
Validates the current ConfigVersion's compatibility and provides migration instructions.
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.
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.
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.
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...
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.
SetupWizardMode
Determines if the SetupWizard will run.