Yaml config files

This commit is contained in:
AffectedArc07
2021-01-16 12:40:14 +00:00
parent 52521bd2f1
commit e77e8dae56
5 changed files with 22 additions and 13 deletions
+6 -6
View File
@@ -78,19 +78,19 @@ Note that this container is meant to be long running. Updates are handled intern
Note that automatic configuration reloading is currently not supported in the container. See #1143
If using manual configuration, before starting your container make sure the aforementioned `appsettings.Production.json` is setup properly. See below
If using manual configuration, before starting your container make sure the aforementioned `appsettings.Production.yml` is setup properly. See below
### Configuring
The first time you run TGS4 you should be prompted with a configuration wizard which will guide you through setting up your appsettings.Production.json
The first time you run TGS4 you should be prompted with a configuration wizard which will guide you through setting up your `appsettings.Production.yml`
This wizard will, generally, run whenever the server is launched without detecting the config json. Follow the instructions below to perform this process manually.
This wizard will, generally, run whenever the server is launched without detecting the config yml. Follow the instructions below to perform this process manually.
#### Configuration Methods
There are 3 primary supported ways to configure TGS:
- Modify the `appsettings.Production.json` file (Recommended).
- Modify the `appsettings.Production.yml` file (Recommended).
- Set environment variables in the form `Section__Subsection=value` or `Section__ArraySubsection__0=value` for arrays.
- Set command line arguments in the form `--Section:Subsection=value` or `--Section:ArraySubsection:0=value` for arrays.
@@ -98,7 +98,7 @@ The latter two are not recommended as they cannot be dynamically changed at runt
#### Manual Configuration
Create an `appsettings.Production.json` file next to `appsettings.json`. This will override the default settings in appsettings.json with your production settings. There are a few keys meant to be changed by hosts. Modifying any config files while the server is running will trigger a safe restart (Keeps DreamDaemon instances running). Note these are all case-sensitive:
Create an `appsettings.Production.yml` file next to `appsettings.json`. This will override the default settings in `appsettings.json` with your production settings. There are a few keys meant to be changed by hosts. Modifying any config files while the server is running will trigger a safe restart (Keeps DreamDaemon instances running). Note these are all case-sensitive:
- `General:ConfigVersion`: Suppresses warnings about out of date config versions. You should change this after updating TGS to one with a new config version. The current version can be found on the releases page for your server version (This field did not exist before v4.4.0).
@@ -250,7 +250,7 @@ var/global/client_count = 0
## Remote Access
tgstation-server is an [ASP.Net Core](https://docs.microsoft.com/en-us/aspnet/core/) app based on the Kestrel web server. This section is meant to serve as a general use case overview, but the entire Kestrel configuration can be modified to your liking with the configuration JSON. See [the official documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel) for details.
tgstation-server is an [ASP.Net Core](https://docs.microsoft.com/en-us/aspnet/core/) app based on the Kestrel web server. This section is meant to serve as a general use case overview, but the entire Kestrel configuration can be modified to your liking with the configuration YAML. See [the official documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel) for details.
Exposing the builtin Kestrel server to the internet directly over HTTP is highly not reccommended due to the lack of security. The recommended way to expose tgstation-server to the internet is to host it through a reverse proxy with HTTPS support. Here are some step by step examples to achieve this for major web servers.
+1 -1
View File
@@ -4,7 +4,7 @@
<Import Project="ControlPanelVersion.props" />
<PropertyGroup>
<TgsCoreVersion>4.7.0</TgsCoreVersion>
<TgsConfigVersion>2.2.0</TgsConfigVersion>
<TgsConfigVersion>2.3.0</TgsConfigVersion>
<TgsApiVersion>8.1.1</TgsApiVersion>
<TgsClientVersion>9.1.1</TgsClientVersion>
<TgsDmapiVersion>5.2.10</TgsDmapiVersion>
+5 -1
View File
@@ -49,7 +49,11 @@ namespace Tgstation.Server.Host
var basePath = IOManager.ResolvePath();
IHostBuilder CreateDefaultBuilder() => Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, configuration) => configuration.SetBasePath(basePath));
.ConfigureAppConfiguration((context, builder) => {
builder.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true)
.AddYamlFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.yml", optional: true, reloadOnChange: true); //Allow both appsettings.json and appsettings.yml for backwards compat
});
var setupWizardHostBuilder = CreateDefaultBuilder()
.UseSetupApplication();
@@ -22,6 +22,7 @@ using Tgstation.Server.Host.Core;
using Tgstation.Server.Host.Database;
using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.System;
using YamlDotNet.Serialization;
namespace Tgstation.Server.Host.Setup
{
@@ -841,8 +842,11 @@ namespace Tgstation.Server.Host.Setup
{ SwarmConfiguration.Section, swarmConfiguration },
};
var json = JsonConvert.SerializeObject(map, Formatting.Indented);
var configBytes = Encoding.UTF8.GetBytes(json);
var serializer = new SerializerBuilder().Build();
var serializedYaml = serializer.Serialize(map);
var configBytes = Encoding.UTF8.GetBytes(serializedYaml);
reloadTcs = new TaskCompletionSource<object>();
@@ -863,9 +867,9 @@ namespace Tgstation.Server.Host.Setup
{
await console.WriteAsync(e.Message, true, cancellationToken).ConfigureAwait(false);
await console.WriteAsync(null, true, cancellationToken).ConfigureAwait(false);
await console.WriteAsync("For your convienence, here's the json we tried to write out:", true, cancellationToken).ConfigureAwait(false);
await console.WriteAsync("For your convienence, here's the yaml we tried to write out:", true, cancellationToken).ConfigureAwait(false);
await console.WriteAsync(null, true, cancellationToken).ConfigureAwait(false);
await console.WriteAsync(json, true, cancellationToken).ConfigureAwait(false);
await console.WriteAsync(serializedYaml, true, cancellationToken).ConfigureAwait(false);
await console.WriteAsync(null, true, cancellationToken).ConfigureAwait(false);
await console.WriteAsync("Press any key to exit...", true, cancellationToken).ConfigureAwait(false);
await console.PressAnyKeyAsync(cancellationToken).ConfigureAwait(false);
@@ -930,7 +934,7 @@ namespace Tgstation.Server.Host.Setup
return;
}
var userConfigFileName = String.Format(CultureInfo.InvariantCulture, "appsettings.{0}.json", hostingEnvironment.EnvironmentName);
var userConfigFileName = String.Format(CultureInfo.InvariantCulture, "appsettings.{0}.yml", hostingEnvironment.EnvironmentName);
async Task HandleSetupCancel()
{
@@ -83,6 +83,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.10" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="2.1.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
<PackageReference Include="Octokit" Version="0.48.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.4" />