mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 23:17:20 +01:00
Add UpdateInProgress to ServerInformation
This commit is contained in:
@@ -28,6 +28,11 @@ namespace Tgstation.Server.Api.Models
|
||||
/// </summary>
|
||||
public bool WindowsHost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If there is a server update in progress.
|
||||
/// </summary>
|
||||
public bool UpdateInProgress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="ICollection{T}"/> of connected <see cref="SwarmServer"/>s.
|
||||
/// </summary>
|
||||
|
||||
@@ -73,6 +73,11 @@ namespace Tgstation.Server.Host.Controllers
|
||||
/// </summary>
|
||||
readonly ISwarmService swarmService;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IServerControl"/> for the <see cref="HomeController"/>.
|
||||
/// </summary>
|
||||
readonly IServerControl serverControl;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IBrowserResolver"/> for the <see cref="HomeController"/>
|
||||
/// </summary>
|
||||
@@ -102,6 +107,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
/// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/>.</param>
|
||||
/// <param name="browserResolver">The value of <see cref="browserResolver"/></param>
|
||||
/// <param name="swarmService">The value of <see cref="swarmService"/>.</param>
|
||||
/// <param name="serverControl">The value of <see cref="serverControl"/>.</param>
|
||||
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
|
||||
/// <param name="controlPanelConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="controlPanelConfiguration"/></param>
|
||||
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="ApiController"/></param>
|
||||
@@ -117,6 +123,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
IPlatformIdentifier platformIdentifier,
|
||||
IBrowserResolver browserResolver,
|
||||
ISwarmService swarmService,
|
||||
IServerControl serverControl,
|
||||
IOptions<GeneralConfiguration> generalConfigurationOptions,
|
||||
IOptions<ControlPanelConfiguration> controlPanelConfigurationOptions,
|
||||
ILogger<HomeController> logger)
|
||||
@@ -135,6 +142,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
this.oAuthProviders = oAuthProviders ?? throw new ArgumentNullException(nameof(oAuthProviders));
|
||||
this.browserResolver = browserResolver ?? throw new ArgumentNullException(nameof(browserResolver));
|
||||
this.swarmService = swarmService ?? throw new ArgumentNullException(nameof(swarmService));
|
||||
this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl));
|
||||
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
|
||||
controlPanelConfiguration = controlPanelConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions));
|
||||
}
|
||||
@@ -186,7 +194,8 @@ namespace Tgstation.Server.Host.Controllers
|
||||
ValidInstancePaths = generalConfiguration.ValidInstancePaths,
|
||||
WindowsHost = platformIdentifier.IsWindows,
|
||||
SwarmServers = swarmService.GetSwarmServers(),
|
||||
OAuthProviderInfos = await oAuthProviders.ProviderInfos(cancellationToken).ConfigureAwait(false)
|
||||
OAuthProviderInfos = await oAuthProviders.ProviderInfos(cancellationToken).ConfigureAwait(false),
|
||||
UpdateInProgress = serverControl.UpdateInProgress,
|
||||
});
|
||||
}
|
||||
#pragma warning restore CA1506
|
||||
|
||||
@@ -15,6 +15,11 @@ namespace Tgstation.Server.Host.Core
|
||||
/// </summary>
|
||||
bool WatchdogPresent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the server is currently updating
|
||||
/// </summary>
|
||||
bool UpdateInProgress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Run a new <see cref="Host"/> assembly and stop the current one. This will likely trigger all active <see cref="CancellationToken"/>s
|
||||
/// </summary>
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace Tgstation.Server.Host
|
||||
/// <inheritdoc />
|
||||
public bool RestartRequested { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool UpdateInProgress { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool WatchdogPresent =>
|
||||
#if WATCHDOG_FREE_RESTART
|
||||
@@ -74,11 +77,6 @@ namespace Tgstation.Server.Host
|
||||
/// </summary>
|
||||
Exception propagatedException;
|
||||
|
||||
/// <summary>
|
||||
/// If a server update has been or is being applied
|
||||
/// </summary>
|
||||
bool updating;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="Server"/>
|
||||
/// </summary>
|
||||
@@ -181,13 +179,13 @@ namespace Tgstation.Server.Host
|
||||
|
||||
lock (restartLock)
|
||||
{
|
||||
if (updating || RestartRequested)
|
||||
if (UpdateInProgress || RestartRequested)
|
||||
{
|
||||
logger.LogTrace("Aborted due to concurrency conflict!");
|
||||
return false;
|
||||
}
|
||||
|
||||
updating = true;
|
||||
UpdateInProgress = true;
|
||||
}
|
||||
|
||||
async void RunUpdate()
|
||||
@@ -244,7 +242,7 @@ namespace Tgstation.Server.Host
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
updating = false;
|
||||
UpdateInProgress = false;
|
||||
try
|
||||
{
|
||||
// important to not leave this directory around if possible
|
||||
@@ -271,7 +269,7 @@ namespace Tgstation.Server.Host
|
||||
}
|
||||
finally
|
||||
{
|
||||
updating = false;
|
||||
UpdateInProgress = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +319,7 @@ namespace Tgstation.Server.Host
|
||||
|
||||
lock (restartLock)
|
||||
{
|
||||
if ((updating && newVersion == null) || RestartRequested)
|
||||
if ((UpdateInProgress && newVersion == null) || RestartRequested)
|
||||
{
|
||||
logger.LogTrace("Aborted due to concurrency conflict!");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user