Skip to content

Commit

Permalink
Merge pull request #1600 from tgstation/FixElasticsearch [TGSDeploy]
Browse files Browse the repository at this point in the history
Elasticsearch configuration improvements
  • Loading branch information
Cyberboss committed Jul 15, 2023
2 parents d8aa9ae + 70a20ae commit a605dd9
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 26 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ Follow the instructions for your OS below.

Note that the Windows Service and installer executables require administrative privileges. These are digitally signed against the Root CA managed by [Jordan Dominion](https://github.com/Cyberboss). Consider installing the certificate into your `Trusted Root Authorities` store for cleaner UAC prompts. The certificate can be downloaded [here](https://file.house/zpFb.cer), please validate the thumbprint is `70176acf7ffa2898fa5b5cd6e38b43b38ea5d07f` before installing. The OCSP server for this is `http://ocsp.dextraspace.net`.

##### Installer

[Download the latest release's tgstation-server-installer.exe](https://github.com/tgstation/tgstation-server/releases/latest). Executing it will take you through the process of installing and configuring your server. The required dotnet runtime may be installed as a pre-requisite.

Note: If you use the `/silent` or `/passive` arguments to the installer, you will need to either pre-configure TGS or configure and start the `tgstation-server` service after installing. A shortcut will be placed on your desktop and in your start menu to assist with this.

##### winget (Windows 10 or later)

[winget](https://github.com/microsoft/winget-cli) installed is the easiest way to install the latest version of tgstation-server (provided Microsoft has approved the most recent package manifest).
Expand Down Expand Up @@ -77,11 +83,7 @@ The required dotnet runtime may be installed as a pre-requisite.

Note: If you use the `-h` or `--disable-interactivity` winget arguments, you will need to either pre-configure TGS or configure and start the `tgstation-server` service after installing. A shortcut will be placed on your desktop and in your start menu to assist with this.

##### Installer

[Download the latest release's tgstation-server-installer.exe](https://github.com/tgstation/tgstation-server/releases/latest). Executing it will take you through the process of installing and configuring your server. The required dotnet runtime may be installed as a pre-requisite.

Note: If you use the `/silent` or `/passive` arguments to the installer, you will need to either pre-configure TGS or configure and start the `tgstation-server` service after installing. A shortcut will be placed on your desktop and in your start menu to assist with this.
Note: The `winget` package is submitted to Microsoft for approval once TGS releases. This means the winget version may be out of date with the current release version. You can always use the TGS updater after installing. You can see the versions still awaiting approval [here](https://github.com/microsoft/winget-pkgs/pulls?q=is%3Apr+is%3Aopen+Tgstation.Server).

##### Manual

Expand Down
4 changes: 2 additions & 2 deletions build/Version.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<!-- Integration tests will ensure they match across the board -->
<Import Project="ControlPanelVersion.props" />
<PropertyGroup>
<TgsCoreVersion>5.13.1</TgsCoreVersion>
<TgsConfigVersion>4.7.0</TgsConfigVersion>
<TgsCoreVersion>5.13.2</TgsCoreVersion>
<TgsConfigVersion>4.7.1</TgsConfigVersion>
<TgsApiVersion>9.11.0</TgsApiVersion>
<TgsCommonLibraryVersion>6.0.0</TgsCommonLibraryVersion>
<TgsApiLibraryVersion>11.0.0</TgsApiLibraryVersion>
Expand Down
8 changes: 4 additions & 4 deletions src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,15 @@ public Task HandleRestart(Version updateVersion, bool handlerMayDelayShutdownWit
var message = updateVersion == null
? $"TGS: {(handlerMayDelayShutdownWithExtremelyLongRunningTasks ? "Graceful shutdown" : "Going down")}..."
: $"TGS: Updating to version {updateVersion}...";
List<ulong> wdChannels;
List<ulong> systemChannels;
lock (mappedChannels) // so it doesn't change while we're using it
wdChannels = mappedChannels
.Where(x => !x.Value.IsSystemChannel)
systemChannels = mappedChannels
.Where(x => x.Value.IsSystemChannel)
.Select(x => x.Key)
.ToList();

return SendMessage(
wdChannels,
systemChannels,
null,
new MessageContent
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Tgstation.Server.Host.Configuration
using System;

namespace Tgstation.Server.Host.Configuration
{
/// <summary>
/// Configuration options pertaining to elasticsearch log storage.
Expand All @@ -18,7 +20,7 @@ public sealed class ElasticsearchConfiguration
/// <summary>
/// The host of the elasticsearch endpoint.
/// </summary>
public string Host { get; set; }
public Uri Host { get; set; }

/// <summary>
/// Username for elasticsearch.
Expand Down
6 changes: 1 addition & 5 deletions src/Tgstation.Server.Host/Core/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ logLevel switch
rollOnFileSizeLimit: true);
},
elasticsearchConfiguration.Enable
? new ElasticsearchSinkOptions(
new Uri(
String.IsNullOrWhiteSpace(elasticsearchConfiguration.Host)
? throw new InvalidOperationException($"Missing {ElasticsearchConfiguration.Section}:{nameof(elasticsearchConfiguration.Host)}!")
: elasticsearchConfiguration.Host))
? new ElasticsearchSinkOptions(elasticsearchConfiguration.Host ?? throw new InvalidOperationException($"Missing {ElasticsearchConfiguration.Section}:{nameof(elasticsearchConfiguration.Host)}!"))
{
// Yes I know this means they cannot use a self signed cert unless they also have authentication, but lets be real here
// No one is going to be doing one of those but not the other
Expand Down
14 changes: 8 additions & 6 deletions src/Tgstation.Server.Host/Setup/SetupWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -790,11 +790,17 @@ async Task<ElasticsearchConfiguration> ConfigureElasticsearch(CancellationToken
do
{
await console.WriteAsync("ElasticSearch server endpoint (Include protocol and port, leave blank for http://127.0.0.1:9200): ", false, cancellationToken);
elasticsearchConfiguration.Host = await console.ReadLineAsync(false, cancellationToken);
if (!String.IsNullOrWhiteSpace(elasticsearchConfiguration.Host))
var hostString = await console.ReadLineAsync(false, cancellationToken);
if (String.IsNullOrWhiteSpace(hostString))
hostString = "http://127.0.0.1:9200";

if (Uri.TryCreate(hostString, UriKind.Absolute, out var host))
{
elasticsearchConfiguration.Host = host;
break;
}

await console.WriteAsync("Invalid URI!", true, cancellationToken);
}
while (true);

Expand All @@ -803,9 +809,7 @@ async Task<ElasticsearchConfiguration> ConfigureElasticsearch(CancellationToken
await console.WriteAsync("Enter Elasticsearch username: ", false, cancellationToken);
elasticsearchConfiguration.Username = await console.ReadLineAsync(false, cancellationToken);
if (!String.IsNullOrWhiteSpace(elasticsearchConfiguration.Username))
{
break;
}
}
while (true);

Expand All @@ -814,9 +818,7 @@ async Task<ElasticsearchConfiguration> ConfigureElasticsearch(CancellationToken
await console.WriteAsync("Enter password: ", false, cancellationToken);
elasticsearchConfiguration.Password = await console.ReadLineAsync(true, cancellationToken);
if (!String.IsNullOrWhiteSpace(elasticsearchConfiguration.Username))
{
break;
}
}
while (true);
}
Expand Down
13 changes: 11 additions & 2 deletions tests/Tgstation.Server.Host.Tests/Setup/TestSetupWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ public async Task TestWithUserStupidity()
//logging config
"no",
// elasticsearch config
"n", // were not validating this travesty in CI
"y",
String.Empty,
String.Empty,
"user",
String.Empty,
"pass",
//cp config
"y",
"y",
Expand Down Expand Up @@ -267,7 +272,11 @@ public async Task TestWithUserStupidity()
"None",
"Critical",
// elasticsearch config
"n", // were not validating this travesty in CI
"y",
"bad url",
"http://localhost:929",
"user",
"pass",
//cp config
"y",
"n",
Expand Down

0 comments on commit a605dd9

Please sign in to comment.