mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 08:33:19 +01:00
Implement configurable restart timeout
This commit is contained in:
@@ -23,6 +23,11 @@ namespace Tgstation.Server.Host.Configuration
|
||||
/// </summary>
|
||||
const int DefaultByondTopicTimeout = 5000;
|
||||
|
||||
/// <summary>
|
||||
/// The default value for <see cref="RestartTimeout"/>
|
||||
/// </summary>
|
||||
const int DefaultRestartTimeout = 10000;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum length of database user passwords
|
||||
/// </summary>
|
||||
@@ -43,5 +48,10 @@ namespace Tgstation.Server.Host.Configuration
|
||||
/// The timeout in milliseconds for sending and receiving topics to/from DreamDaemon. Note that a single topic exchange can take up to twice this value
|
||||
/// </summary>
|
||||
public int ByondTopicTimeout { get; set; } = DefaultByondTopicTimeout;
|
||||
|
||||
/// <summary>
|
||||
/// The timeout milliseconds for restarting the server
|
||||
/// </summary>
|
||||
public int RestartTimeout { get; set; } = DefaultRestartTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.IO;
|
||||
|
||||
@@ -43,6 +45,11 @@ namespace Tgstation.Server.Host
|
||||
/// </summary>
|
||||
ILogger<Server> logger;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GeneralConfiguration"/> for the <see cref="Server"/>
|
||||
/// </summary>
|
||||
GeneralConfiguration generalConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="cancellationTokenSource"/> for the <see cref="Server"/>
|
||||
/// </summary>
|
||||
@@ -115,6 +122,8 @@ namespace Tgstation.Server.Host
|
||||
try
|
||||
{
|
||||
logger = webHost.Services.GetRequiredService<ILogger<Server>>();
|
||||
var generalConfigurationOptions = webHost.Services.GetRequiredService<IOptions<GeneralConfiguration>>();
|
||||
generalConfiguration = generalConfigurationOptions.Value;
|
||||
await webHost.RunAsync(cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
@@ -264,8 +273,7 @@ namespace Tgstation.Server.Host
|
||||
var cancellationToken = cts.Token;
|
||||
var eventsTask = Task.WhenAll(restartHandlers.Select(x => x.HandleRestart(newVersion, cancellationToken)).ToList());
|
||||
|
||||
// YA GOT 10 SECONDS
|
||||
var expiryTask = Task.Delay(TimeSpan.FromSeconds(10));
|
||||
var expiryTask = Task.Delay(TimeSpan.FromMilliseconds(generalConfiguration.RestartTimeout));
|
||||
await Task.WhenAny(eventsTask, expiryTask).ConfigureAwait(false);
|
||||
logger.LogTrace("Joining restart handlers...");
|
||||
cts.Cancel();
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"MinimumPasswordLength": 15,
|
||||
"GitHubAccessToken": null,
|
||||
"SetupWizardMode": "AutoDetect",
|
||||
"ByondTopicTimeout": 5000
|
||||
"ByondTopicTimeout": 5000,
|
||||
"RestartTimeout": 10000
|
||||
},
|
||||
"FileLogging": {
|
||||
"Directory": null, //use the default path
|
||||
|
||||
Reference in New Issue
Block a user