mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 16:39:21 +01:00
Fix reattaching again
This commit is contained in:
@@ -11,6 +11,6 @@ namespace Tgstation.Server.Host.Components.Interop
|
||||
/// Used to identify and authenticate the DreamDaemon instance
|
||||
/// </summary>
|
||||
[Required]
|
||||
public virtual string AccessIdentifier { get; set; }
|
||||
public string AccessIdentifier { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -157,16 +156,13 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <inheritdoc />
|
||||
protected sealed override async Task InitControllers(Action callBeforeRecurse, Task chatTask, WatchdogReattachInformation reattachInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
Debug.Assert(Server == null, "Entered LaunchNoLock with server not being null!");
|
||||
|
||||
// don't need a new dmb if reattaching
|
||||
var doesntNeedNewDmb = reattachInfo?.Alpha != null && reattachInfo?.Bravo != null;
|
||||
var dmbToUse = doesntNeedNewDmb ? null : DmbFactory.LockNextDmb(1);
|
||||
|
||||
var serverToReattach = reattachInfo?.Alpha ?? reattachInfo?.Bravo;
|
||||
var serverToKill = reattachInfo?.Bravo ?? reattachInfo?.Alpha;
|
||||
|
||||
// vice versa
|
||||
if (serverToKill == serverToReattach)
|
||||
serverToKill = null;
|
||||
|
||||
if (reattachInfo?.AlphaIsActive == false)
|
||||
{
|
||||
var temp = serverToReattach;
|
||||
@@ -174,6 +170,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
serverToKill = temp;
|
||||
}
|
||||
|
||||
// don't need a new dmb if reattaching
|
||||
var doesntNeedNewDmb = serverToReattach != null;
|
||||
var dmbToUse = doesntNeedNewDmb ? null : DmbFactory.LockNextDmb(1);
|
||||
|
||||
// if this try catches something, both servers are killed
|
||||
bool inactiveServerWasKilled = false;
|
||||
try
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Interop.Bridge;
|
||||
using Tgstation.Server.Host.Models;
|
||||
@@ -22,20 +21,6 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// </summary>
|
||||
public RuntimeInformation RuntimeInformation { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DreamDaemonSecurity? LaunchSecurityLevel
|
||||
{
|
||||
get => RuntimeInformation.SecurityLevel ?? base.LaunchSecurityLevel;
|
||||
set => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string AccessIdentifier
|
||||
{
|
||||
get => base.AccessIdentifier;
|
||||
set => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see langword="lock"/> <see cref="object"/> for accessing <see cref="RuntimeInformation"/>.
|
||||
/// </summary>
|
||||
@@ -47,7 +32,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <param name="dmb">The value of <see cref="Dmb"/>.</param>
|
||||
/// <param name="process">The <see cref="IProcess"/> used to get the <see cref="ReattachInformationBase.ProcessId"/>.</param>
|
||||
/// <param name="runtimeInformation">The value of <see cref="RuntimeInformation"/>.</param>
|
||||
/// <param name="accessIdentifier">The value of <see cref="AccessIdentifier"/>.</param>
|
||||
/// <param name="accessIdentifier">The value of <see cref="Interop.DMApiParameters.AccessIdentifier"/>.</param>
|
||||
/// <param name="port">The value of <see cref="ReattachInformationBase.Port"/>.</param>
|
||||
/// <param name="isPrimary">The value of <see cref="ReattachInformationBase.IsPrimary"/>.</param>
|
||||
internal ReattachInformation(
|
||||
@@ -64,9 +49,9 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
if (!runtimeInformation.SecurityLevel.HasValue)
|
||||
throw new ArgumentException("runtimeInformation must have a valid SecurityLevel!", nameof(runtimeInformation));
|
||||
|
||||
base.AccessIdentifier = accessIdentifier ?? throw new ArgumentNullException(nameof(accessIdentifier));
|
||||
AccessIdentifier = accessIdentifier ?? throw new ArgumentNullException(nameof(accessIdentifier));
|
||||
|
||||
base.LaunchSecurityLevel = runtimeInformation.SecurityLevel.Value;
|
||||
LaunchSecurityLevel = runtimeInformation.SecurityLevel.Value;
|
||||
Port = port;
|
||||
IsPrimary = isPrimary;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Tgstation.Server.Host.Models
|
||||
/// The <see cref="DreamDaemonSecurity"/> level DreamDaemon was launched with.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public virtual DreamDaemonSecurity? LaunchSecurityLevel { get; set; }
|
||||
public DreamDaemonSecurity? LaunchSecurityLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="ReattachInformationBase"/>
|
||||
|
||||
@@ -55,30 +55,28 @@ namespace Tgstation.Server.Host
|
||||
var updatedArgsArray = listArgs.ToArray();
|
||||
try
|
||||
{
|
||||
using (var shutdownNotifier = new ProgramShutdownTokenSource())
|
||||
using var shutdownNotifier = new ProgramShutdownTokenSource();
|
||||
var cancellationToken = shutdownNotifier.Token;
|
||||
IServer server;
|
||||
try
|
||||
{
|
||||
var cancellationToken = shutdownNotifier.Token;
|
||||
IServer server;
|
||||
try
|
||||
{
|
||||
server = await ServerFactory.CreateServer(updatedArgsArray, updatePath, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Console cancelled
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (server == null)
|
||||
return 0;
|
||||
|
||||
try
|
||||
{
|
||||
await server.Run(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
return server.RestartRequested ? 1 : 0;
|
||||
server = await ServerFactory.CreateServer(updatedArgsArray, updatePath, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Console cancelled
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (server == null)
|
||||
return 0;
|
||||
|
||||
try
|
||||
{
|
||||
await server.Run(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
return server.RestartRequested ? 1 : 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user