mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-23 21:16:52 +01:00
Split up the Watchdog namespace into Session
This commit is contained in:
@@ -11,6 +11,7 @@ using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Byond;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Repository;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Components.Watchdog;
|
||||
using Tgstation.Server.Host.IO;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
|
||||
@@ -9,6 +9,7 @@ using Tgstation.Server.Host.Components.Chat.Commands;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Interop;
|
||||
using Tgstation.Server.Host.Components.Repository;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Components.Watchdog;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Tgstation.Server.Host.Components.Watchdog;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Status of DMAPI validation
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Tgstation.Server.Host.Components.Interop.Topic;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Combines a <see cref="global::Byond.TopicSender.TopicResponse"/> with a <see cref="TopicResponse"/>.
|
||||
+1
-1
@@ -4,7 +4,7 @@ using System.Threading.Tasks;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Interop.Topic;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements a fake "dead" <see cref="ISessionController"/>
|
||||
+8
-8
@@ -3,12 +3,12 @@ using System.Globalization;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Models;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Reattach information for a <see cref="IWatchdog"/>
|
||||
/// Reattach information for two <see cref="ISessionController"/>
|
||||
/// </summary>
|
||||
public sealed class WatchdogReattachInformation : WatchdogReattachInformationBase
|
||||
public sealed class DualReattachInformation : DualReattachInformationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="ReattachInformation"/> for the Alpha session
|
||||
@@ -21,17 +21,17 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
public ReattachInformation Bravo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="WatchdogReattachInformation"/>
|
||||
/// Construct a <see cref="DualReattachInformation"/>
|
||||
/// </summary>
|
||||
public WatchdogReattachInformation() { }
|
||||
public DualReattachInformation() { }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="WatchdogReattachInformation"/> from a given <paramref name="copy"/> with a given <paramref name="dmbAlpha"/> and <paramref name="dmbBravo"/>
|
||||
/// Construct a <see cref="DualReattachInformation"/> from a given <paramref name="copy"/> with a given <paramref name="dmbAlpha"/> and <paramref name="dmbBravo"/>
|
||||
/// </summary>
|
||||
/// <param name="copy">The <see cref="WatchdogReattachInformationBase"/> to copy information from</param>
|
||||
/// <param name="copy">The <see cref="DualReattachInformationBase"/> to copy information from</param>
|
||||
/// <param name="dmbAlpha">The <see cref="IDmbProvider"/> used to build <see cref="Alpha"/></param>
|
||||
/// <param name="dmbBravo">The <see cref="IDmbProvider"/> used to build <see cref="Bravo"/></param>
|
||||
public WatchdogReattachInformation(Models.WatchdogReattachInformation copy, IDmbProvider dmbAlpha, IDmbProvider dmbBravo) : base(copy)
|
||||
public DualReattachInformation(Models.DualReattachInformation copy, IDmbProvider dmbAlpha, IDmbProvider dmbBravo) : base(copy)
|
||||
{
|
||||
if (copy.Alpha != null)
|
||||
Alpha = new ReattachInformation(copy.Alpha, dmbAlpha);
|
||||
+7
-7
@@ -1,26 +1,26 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles saving and loading <see cref="WatchdogReattachInformation"/>
|
||||
/// Handles saving and loading <see cref="DualReattachInformation"/>
|
||||
/// </summary>
|
||||
public interface IReattachInfoHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Save some <paramref name="reattachInformation"/>
|
||||
/// </summary>
|
||||
/// <param name="reattachInformation">The <see cref="WatchdogReattachInformation"/> to save</param>
|
||||
/// <param name="reattachInformation">The <see cref="DualReattachInformation"/> to save</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Save(WatchdogReattachInformation reattachInformation, CancellationToken cancellationToken);
|
||||
Task Save(DualReattachInformation reattachInformation, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Load a saved <see cref="WatchdogReattachInformation"/>
|
||||
/// Load a saved <see cref="DualReattachInformation"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the stored <see cref="WatchdogReattachInformation"/> if any</returns>
|
||||
Task<WatchdogReattachInformation> Load(CancellationToken cancellationToken);
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the stored <see cref="DualReattachInformation"/> if any</returns>
|
||||
Task<DualReattachInformation> Load(CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -5,7 +5,7 @@ using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Interop.Topic;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles communication with a DreamDaemon <see cref="IProcess"/>
|
||||
@@ -28,7 +28,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
bool TerminationWasRequested { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The DMAPI <see cref="Watchdog.ApiValidationStatus"/>
|
||||
/// The DMAPI <see cref="Session.ApiValidationStatus"/>
|
||||
/// </summary>
|
||||
ApiValidationStatus ApiValidationStatus { get; }
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Byond;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Factory for <see cref="ISessionController"/>s
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the result of trying to start a DD process
|
||||
+6
-7
@@ -5,11 +5,10 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Watchdog;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Z.EntityFramework.Plus;
|
||||
|
||||
namespace Tgstation.Server.Host.Components
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <inheritdoc />
|
||||
sealed class ReattachInfoHandler : IReattachInfoHandler
|
||||
@@ -50,7 +49,7 @@ namespace Tgstation.Server.Host.Components
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task Save(WatchdogReattachInformation reattachInformation, CancellationToken cancellationToken) => databaseContextFactory.UseContext(async (db) =>
|
||||
public Task Save(DualReattachInformation reattachInformation, CancellationToken cancellationToken) => databaseContextFactory.UseContext(async (db) =>
|
||||
{
|
||||
if (reattachInformation == null)
|
||||
throw new ArgumentNullException(nameof(reattachInformation));
|
||||
@@ -78,7 +77,7 @@ namespace Tgstation.Server.Host.Components
|
||||
|
||||
await deleteTask.ConfigureAwait(false);
|
||||
|
||||
db.WatchdogReattachInformations.Add(new Models.WatchdogReattachInformation
|
||||
db.WatchdogReattachInformations.Add(new Models.DualReattachInformation
|
||||
{
|
||||
Alpha = ConvertReattachInfo(reattachInformation.Alpha),
|
||||
Bravo = ConvertReattachInfo(reattachInformation.Bravo),
|
||||
@@ -89,9 +88,9 @@ namespace Tgstation.Server.Host.Components
|
||||
});
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<WatchdogReattachInformation> Load(CancellationToken cancellationToken)
|
||||
public async Task<DualReattachInformation> Load(CancellationToken cancellationToken)
|
||||
{
|
||||
Models.WatchdogReattachInformation result = null;
|
||||
Models.DualReattachInformation result = null;
|
||||
await databaseContextFactory.UseContext(async (db) =>
|
||||
{
|
||||
var instance = await db.Instances.Where(x => x.Id == metadata.Id)
|
||||
@@ -117,7 +116,7 @@ namespace Tgstation.Server.Host.Components
|
||||
: Task.FromResult<IDmbProvider>(null);
|
||||
|
||||
var bravoDmbTask = GetDmbForReattachInfo(result.Bravo);
|
||||
var info = new WatchdogReattachInformation(result, await GetDmbForReattachInfo(result.Alpha).ConfigureAwait(false), await bravoDmbTask.ConfigureAwait(false));
|
||||
var info = new DualReattachInformation(result, await GetDmbForReattachInfo(result.Alpha).ConfigureAwait(false), await bravoDmbTask.ConfigureAwait(false));
|
||||
logger.LogDebug("Reattach information loaded: {0}", info);
|
||||
return info;
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Tgstation.Server.Host.Components.Interop.Bridge;
|
||||
using Tgstation.Server.Host.Models;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters necessary for duplicating a <see cref="ISessionController"/> session
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the action to take when /world/Reboot() is called
|
||||
+1
-1
@@ -17,7 +17,7 @@ using Tgstation.Server.Host.Components.Interop.Bridge;
|
||||
using Tgstation.Server.Host.Components.Interop.Topic;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <inheritdoc />
|
||||
sealed class SessionController : ISessionController, IBridgeHandler, IChannelSink
|
||||
+1
-1
@@ -18,7 +18,7 @@ using Tgstation.Server.Host.IO;
|
||||
using Tgstation.Server.Host.Security;
|
||||
using Tgstation.Server.Host.System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
namespace Tgstation.Server.Host.Components.Session
|
||||
{
|
||||
/// <inheritdoc />
|
||||
sealed class SessionControllerFactory : ISessionControllerFactory
|
||||
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
@@ -107,7 +108,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
case MonitorActivationReason.ActiveServerCrashed:
|
||||
string exitWord = Server.TerminationWasRequested ? "exited" : "crashed";
|
||||
if (Server.RebootState == Watchdog.RebootState.Shutdown)
|
||||
if (Server.RebootState == Session.RebootState.Shutdown)
|
||||
{
|
||||
// the time for graceful shutdown is now
|
||||
await Chat.SendWatchdogMessage(
|
||||
@@ -136,10 +137,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
break;
|
||||
case MonitorActivationReason.ActiveServerRebooted:
|
||||
var rebootState = Server.RebootState;
|
||||
if (gracefulRebootRequired && rebootState == Watchdog.RebootState.Normal)
|
||||
if (gracefulRebootRequired && rebootState == Session.RebootState.Normal)
|
||||
{
|
||||
Logger.LogError("Watchdog reached normal reboot state with gracefulRebootRequired set!");
|
||||
rebootState = Watchdog.RebootState.Restart;
|
||||
rebootState = Session.RebootState.Restart;
|
||||
}
|
||||
|
||||
gracefulRebootRequired = false;
|
||||
@@ -147,13 +148,13 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
|
||||
switch (rebootState)
|
||||
{
|
||||
case Watchdog.RebootState.Normal:
|
||||
case Session.RebootState.Normal:
|
||||
monitorState.NextAction = HandleNormalReboot();
|
||||
break;
|
||||
case Watchdog.RebootState.Restart:
|
||||
case Session.RebootState.Restart:
|
||||
monitorState.NextAction = MonitorAction.Restart;
|
||||
break;
|
||||
case Watchdog.RebootState.Shutdown:
|
||||
case Session.RebootState.Shutdown:
|
||||
// graceful shutdown time
|
||||
await Chat.SendWatchdogMessage(
|
||||
"Active server rebooted! Shutting down due to graceful termination request...",
|
||||
@@ -168,7 +169,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
|
||||
break;
|
||||
case MonitorActivationReason.ActiveLaunchParametersUpdated:
|
||||
await Server.SetRebootState(Watchdog.RebootState.Restart, cancellationToken).ConfigureAwait(false);
|
||||
await Server.SetRebootState(Session.RebootState.Restart, cancellationToken).ConfigureAwait(false);
|
||||
gracefulRebootRequired = true;
|
||||
break;
|
||||
case MonitorActivationReason.NewDmbAvailable:
|
||||
@@ -185,8 +186,8 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected sealed override WatchdogReattachInformation CreateReattachInformation()
|
||||
=> new WatchdogReattachInformation
|
||||
protected sealed override DualReattachInformation CreateReattachInformation()
|
||||
=> new DualReattachInformation
|
||||
{
|
||||
AlphaIsActive = true,
|
||||
Alpha = Server?.Release()
|
||||
@@ -205,7 +206,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
protected sealed override ISessionController GetActiveController() => Server;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected sealed override async Task InitControllers(Action callBeforeRecurse, Task chatTask, WatchdogReattachInformation reattachInfo, CancellationToken cancellationToken)
|
||||
protected sealed override async Task InitControllers(Action callBeforeRecurse, Task chatTask, DualReattachInformation reattachInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
var serverToReattach = reattachInfo?.Alpha ?? reattachInfo?.Bravo;
|
||||
var serverToKill = reattachInfo?.Bravo ?? reattachInfo?.Alpha;
|
||||
@@ -310,7 +311,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
protected virtual Task HandleNewDmbAvailable(CancellationToken cancellationToken)
|
||||
{
|
||||
gracefulRebootRequired = true;
|
||||
return Server.SetRebootState(Watchdog.RebootState.Restart, cancellationToken);
|
||||
return Server.SetRebootState(Session.RebootState.Restart, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
@@ -229,7 +230,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
switch (activationReason)
|
||||
{
|
||||
case MonitorActivationReason.ActiveServerCrashed:
|
||||
if (monitorState.ActiveServer.RebootState == Watchdog.RebootState.Shutdown)
|
||||
if (monitorState.ActiveServer.RebootState == Session.RebootState.Shutdown)
|
||||
{
|
||||
// the time for graceful shutdown is now
|
||||
await Chat.SendWatchdogMessage(
|
||||
@@ -293,7 +294,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
var rebootState = monitorState.ActiveServer.RebootState;
|
||||
monitorState.ActiveServer.ResetRebootState(); // the DMAPI has already done this internally
|
||||
|
||||
if (FullRestartDeadInactive() && rebootState != Watchdog.RebootState.Shutdown)
|
||||
if (FullRestartDeadInactive() && rebootState != Session.RebootState.Shutdown)
|
||||
break; // full restart if the inactive server is being fucky
|
||||
|
||||
// what matters here is the RebootState
|
||||
@@ -301,14 +302,14 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
|
||||
switch (rebootState)
|
||||
{
|
||||
case Watchdog.RebootState.Normal:
|
||||
case Session.RebootState.Normal:
|
||||
// life as normal
|
||||
break;
|
||||
case Watchdog.RebootState.Restart:
|
||||
case Session.RebootState.Restart:
|
||||
// reboot the current active server once the inactive one activates
|
||||
restartOnceSwapped = true;
|
||||
break;
|
||||
case Watchdog.RebootState.Shutdown:
|
||||
case Session.RebootState.Shutdown:
|
||||
// graceful shutdown time
|
||||
await Chat.SendWatchdogMessage(
|
||||
"Active server rebooted! Shutting down due to graceful termination request...",
|
||||
@@ -438,7 +439,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
|
||||
/// <inheritdoc />
|
||||
#pragma warning disable CA1502 // TODO: Decomplexify
|
||||
protected override async Task InitControllers(Action callBeforeRecurse, Task chatTask, WatchdogReattachInformation reattachInfo, CancellationToken cancellationToken)
|
||||
protected override async Task InitControllers(Action callBeforeRecurse, Task chatTask, DualReattachInformation reattachInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
Debug.Assert(alphaServer == null && bravoServer == null, "Entered LaunchNoLock with one or more of the servers not being null!");
|
||||
|
||||
@@ -577,8 +578,8 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
protected override ISessionController GetActiveController() => AlphaIsActive ? alphaServer : bravoServer;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override WatchdogReattachInformation CreateReattachInformation()
|
||||
=> new WatchdogReattachInformation
|
||||
protected override DualReattachInformation CreateReattachInformation()
|
||||
=> new DualReattachInformation
|
||||
{
|
||||
AlphaIsActive = AlphaIsActive,
|
||||
Alpha = alphaServer?.Release(),
|
||||
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
@@ -37,7 +38,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
DreamDaemonLaunchParameters LastLaunchParameters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Watchdog.RebootState"/> of the active server
|
||||
/// The <see cref="Session.RebootState"/> of the active server
|
||||
/// </summary>
|
||||
RebootState? RebootState { get; }
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.IO;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Watchdog
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ using Tgstation.Server.Api.Rights;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Interop.Topic;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.Extensions;
|
||||
@@ -104,14 +105,14 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
readonly IRestartRegistration restartRegistration;
|
||||
|
||||
/// <summary>
|
||||
/// If the <see cref="WatchdogBase"/> should <see cref="LaunchImplNoLock(bool, bool, WatchdogReattachInformation, CancellationToken)"/> in <see cref="StartAsync(CancellationToken)"/>
|
||||
/// If the <see cref="WatchdogBase"/> should <see cref="LaunchImplNoLock(bool, bool, DualReattachInformation, CancellationToken)"/> in <see cref="StartAsync(CancellationToken)"/>
|
||||
/// </summary>
|
||||
readonly bool autoStart;
|
||||
|
||||
/// <summary>
|
||||
/// Used when detaching servers.
|
||||
/// </summary>
|
||||
WatchdogReattachInformation releasedReattachInformation;
|
||||
DualReattachInformation releasedReattachInformation;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="CancellationTokenSource"/> for the monitor loop
|
||||
@@ -232,7 +233,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
var toKill = GetActiveController();
|
||||
if (toKill != null)
|
||||
{
|
||||
await toKill.SetRebootState(Watchdog.RebootState.Shutdown, cancellationToken).ConfigureAwait(false);
|
||||
await toKill.SetRebootState(Session.RebootState.Shutdown, cancellationToken).ConfigureAwait(false);
|
||||
Logger.LogTrace("Graceful termination requested");
|
||||
}
|
||||
else
|
||||
@@ -250,7 +251,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
Logger.LogTrace("Sending heartbeat to active server...");
|
||||
var response = await activeServer.SendCommand(new TopicParameters(), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var shouldShutdown = activeServer.RebootState == Watchdog.RebootState.Shutdown;
|
||||
var shouldShutdown = activeServer.RebootState == Session.RebootState.Shutdown;
|
||||
if (response == null)
|
||||
{
|
||||
switch (++heartbeatsMissed)
|
||||
@@ -296,10 +297,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// </summary>
|
||||
/// <param name="startMonitor">If <see cref="MonitorLifetimes(CancellationToken)"/> should be started by this function</param>
|
||||
/// <param name="announce">If the launch should be announced to chat by this function</param>
|
||||
/// <param name="reattachInfo"><see cref="WatchdogReattachInformation"/> to use, if any</param>
|
||||
/// <param name="reattachInfo"><see cref="DualReattachInformation"/> to use, if any</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
protected async Task LaunchImplNoLock(bool startMonitor, bool announce, WatchdogReattachInformation reattachInfo, CancellationToken cancellationToken)
|
||||
protected async Task LaunchImplNoLock(bool startMonitor, bool announce, DualReattachInformation reattachInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
Logger.LogTrace("Begin LaunchImplNoLock");
|
||||
|
||||
@@ -394,7 +395,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a chat message and log about a failed reattach operation and attempts another call to <see cref="LaunchImplNoLock(bool, bool, WatchdogReattachInformation, CancellationToken)"/>.
|
||||
/// Send a chat message and log about a failed reattach operation and attempts another call to <see cref="LaunchImplNoLock(bool, bool, DualReattachInformation, CancellationToken)"/>.
|
||||
/// </summary>
|
||||
/// <param name="inactiveReattachSuccess">If the inactive server was reattached successfully.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation/</param>
|
||||
@@ -445,10 +446,10 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
protected abstract ISessionController GetActiveController();
|
||||
|
||||
/// <summary>
|
||||
/// Create the <see cref="WatchdogReattachInformation"/> for the <see cref="ISessionController"/>s.
|
||||
/// Create the <see cref="DualReattachInformation"/> for the <see cref="ISessionController"/>s.
|
||||
/// </summary>
|
||||
/// <returns>A new <see cref="WatchdogReattachInformation"/>.</returns>
|
||||
protected abstract WatchdogReattachInformation CreateReattachInformation();
|
||||
/// <returns>A new <see cref="DualReattachInformation"/>.</returns>
|
||||
protected abstract DualReattachInformation CreateReattachInformation();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tasks for the following <see cref="MonitorActivationReason"/>s: <see cref="MonitorActivationReason.ActiveServerCrashed"/>, <see cref="MonitorActivationReason.ActiveServerRebooted"/>, <see cref="MonitorActivationReason.InactiveServerCrashed"/>, <see cref="MonitorActivationReason.InactiveServerRebooted"/>, <see cref="MonitorActivationReason.InactiveServerStartupComplete"/>.
|
||||
@@ -677,12 +678,12 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
/// <summary>
|
||||
/// Starts all <see cref="ISessionController"/>s.
|
||||
/// </summary>
|
||||
/// <param name="callBeforeRecurse">An <see cref="Action"/> that must be run before making a recursive call to <see cref="LaunchImplNoLock(bool, bool, WatchdogReattachInformation, CancellationToken)"/>.</param>
|
||||
/// <param name="callBeforeRecurse">An <see cref="Action"/> that must be run before making a recursive call to <see cref="LaunchImplNoLock(bool, bool, DualReattachInformation, CancellationToken)"/>.</param>
|
||||
/// <param name="chatTask">A, possibly active, <see cref="Task"/> for an outgoing chat message.</param>
|
||||
/// <param name="reattachInfo"><see cref="WatchdogReattachInformation"/> to use, if any</param>
|
||||
/// <param name="reattachInfo"><see cref="DualReattachInformation"/> to use, if any</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
protected abstract Task InitControllers(Action callBeforeRecurse, Task chatTask, WatchdogReattachInformation reattachInfo, CancellationToken cancellationToken);
|
||||
protected abstract Task InitControllers(Action callBeforeRecurse, Task chatTask, DualReattachInformation reattachInfo, CancellationToken cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task ChangeSettings(DreamDaemonLaunchParameters launchParameters, CancellationToken cancellationToken)
|
||||
@@ -787,7 +788,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
return;
|
||||
var toClear = GetActiveController();
|
||||
if (toClear != null)
|
||||
await toClear.SetRebootState(Watchdog.RebootState.Normal, cancellationToken).ConfigureAwait(false);
|
||||
await toClear.SetRebootState(Session.RebootState.Normal, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -814,7 +815,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
var toReboot = GetActiveController();
|
||||
if (toReboot != null)
|
||||
{
|
||||
if (!await toReboot.SetRebootState(Watchdog.RebootState.Restart, cancellationToken).ConfigureAwait(false))
|
||||
if (!await toReboot.SetRebootState(Session.RebootState.Restart, cancellationToken).ConfigureAwait(false))
|
||||
Logger.LogWarning("Unable to send reboot state change event!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.IO;
|
||||
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
|
||||
@@ -12,7 +12,7 @@ using Tgstation.Server.Api;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
using Tgstation.Server.Host.Components;
|
||||
using Tgstation.Server.Host.Components.Watchdog;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.Jobs;
|
||||
using Tgstation.Server.Host.Models;
|
||||
|
||||
@@ -83,9 +83,9 @@ namespace Tgstation.Server.Host.Database
|
||||
public DbSet<ReattachInformation> ReattachInformations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="WatchdogReattachInformation"/>s in the <see cref="DatabaseContext{TParentContext}"/>.
|
||||
/// The <see cref="DualReattachInformation"/>s in the <see cref="DatabaseContext{TParentContext}"/>.
|
||||
/// </summary>
|
||||
public DbSet<WatchdogReattachInformation> WatchdogReattachInformations { get; set; }
|
||||
public DbSet<DualReattachInformation> WatchdogReattachInformations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestMerge"/>s in the <see cref="DatabaseContext{TParentContext}"/>
|
||||
@@ -144,7 +144,7 @@ namespace Tgstation.Server.Host.Database
|
||||
IDatabaseCollection<ReattachInformation> IDatabaseContext.ReattachInformations => reattachInformationsCollection;
|
||||
|
||||
/// <inheritdoc />
|
||||
IDatabaseCollection<WatchdogReattachInformation> IDatabaseContext.WatchdogReattachInformations => watchdogReattachInformationsCollection;
|
||||
IDatabaseCollection<DualReattachInformation> IDatabaseContext.WatchdogReattachInformations => watchdogReattachInformationsCollection;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IDatabaseSeeder"/> for the <see cref="DatabaseContext{TParentContext}"/>
|
||||
@@ -214,7 +214,7 @@ namespace Tgstation.Server.Host.Database
|
||||
/// <summary>
|
||||
/// Backing field for <see cref="IDatabaseContext.WatchdogReattachInformations"/>.
|
||||
/// </summary>
|
||||
readonly IDatabaseCollection<WatchdogReattachInformation> watchdogReattachInformationsCollection;
|
||||
readonly IDatabaseCollection<DualReattachInformation> watchdogReattachInformationsCollection;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="DatabaseContext{TParentContext}"/>
|
||||
@@ -241,7 +241,7 @@ namespace Tgstation.Server.Host.Database
|
||||
revisionInformationsCollection = new DatabaseCollection<RevisionInformation>(RevisionInformations);
|
||||
jobsCollection = new DatabaseCollection<Job>(Jobs);
|
||||
reattachInformationsCollection = new DatabaseCollection<ReattachInformation>(ReattachInformations);
|
||||
watchdogReattachInformationsCollection = new DatabaseCollection<WatchdogReattachInformation>(WatchdogReattachInformations);
|
||||
watchdogReattachInformationsCollection = new DatabaseCollection<DualReattachInformation>(WatchdogReattachInformations);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace Tgstation.Server.Host.Database
|
||||
IDatabaseCollection<ReattachInformation> ReattachInformations { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DbSet{TEntity}"/> for <see cref="WatchdogReattachInformation"/>s
|
||||
/// The <see cref="DbSet{TEntity}"/> for <see cref="DualReattachInformation"/>s
|
||||
/// </summary>
|
||||
IDatabaseCollection<WatchdogReattachInformation> WatchdogReattachInformations { get; }
|
||||
IDatabaseCollection<DualReattachInformation> WatchdogReattachInformations { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Saves changes made to the <see cref="IDatabaseContext"/>
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Database representation of <see cref="Components.Watchdog.WatchdogReattachInformation"/>
|
||||
/// Database representation of <see cref="Components.Session.DualReattachInformation"/>
|
||||
/// </summary>
|
||||
public sealed class WatchdogReattachInformation : WatchdogReattachInformationBase
|
||||
public sealed class DualReattachInformation : DualReattachInformationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The row Id
|
||||
@@ -11,7 +11,7 @@
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Api.Models.Instance.Id"/> of the <see cref="Instance"/> the <see cref="WatchdogReattachInformation"/> belongs to
|
||||
/// The <see cref="Api.Models.Instance.Id"/> of the <see cref="Instance"/> the <see cref="DualReattachInformation"/> belongs to
|
||||
/// </summary>
|
||||
public long InstanceId { get; set; }
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for <see cref="DualReattachInformation"/>
|
||||
/// </summary>
|
||||
public abstract class DualReattachInformationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// If the Alpha session is the active session
|
||||
/// </summary>
|
||||
public bool AlphaIsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="DualReattachInformationBase"/>
|
||||
/// </summary>
|
||||
public DualReattachInformationBase() { }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="DualReattachInformation"/> from a given <paramref name="copy"/>
|
||||
/// </summary>
|
||||
/// <param name="copy">The <see cref="DualReattachInformationBase"/> to copy values from</param>
|
||||
protected DualReattachInformationBase(DualReattachInformationBase copy)
|
||||
{
|
||||
AlphaIsActive = copy?.AlphaIsActive ?? throw new ArgumentNullException(nameof(copy));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,9 @@ namespace Tgstation.Server.Host.Models
|
||||
public RepositorySettings RepositorySettings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Models.WatchdogReattachInformation"/> for the <see cref="Instance"/>
|
||||
/// The <see cref="Models.DualReattachInformation"/> for the <see cref="Instance"/>
|
||||
/// </summary>
|
||||
public WatchdogReattachInformation WatchdogReattachInformation { get; set; }
|
||||
public DualReattachInformation WatchdogReattachInformation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="InstanceUser"/>s in the <see cref="Instance"/>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Database representation of <see cref="Components.Watchdog.ReattachInformation"/>
|
||||
/// Database representation of <see cref="Components.Session.ReattachInformation"/>
|
||||
/// </summary>
|
||||
public sealed class ReattachInformation : ReattachInformationBase
|
||||
{
|
||||
@@ -13,7 +13,7 @@ namespace Tgstation.Server.Host.Models
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Models.CompileJob"/> for the <see cref="Components.Watchdog.ReattachInformation.Dmb"/>
|
||||
/// The <see cref="Models.CompileJob"/> for the <see cref="Components.Session.ReattachInformation.Dmb"/>
|
||||
/// </summary>
|
||||
[Required]
|
||||
public CompileJob CompileJob { get; set; }
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Host.Components.Interop;
|
||||
using Tgstation.Server.Host.Components.Watchdog;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for <see cref="WatchdogReattachInformation"/>
|
||||
/// </summary>
|
||||
public abstract class WatchdogReattachInformationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// If the Alpha session is the active session
|
||||
/// </summary>
|
||||
public bool AlphaIsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="WatchdogReattachInformationBase"/>
|
||||
/// </summary>
|
||||
public WatchdogReattachInformationBase() { }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="WatchdogReattachInformation"/> from a given <paramref name="copy"/>
|
||||
/// </summary>
|
||||
/// <param name="copy">The <see cref="WatchdogReattachInformationBase"/> to copy values from</param>
|
||||
protected WatchdogReattachInformationBase(WatchdogReattachInformationBase copy)
|
||||
{
|
||||
AlphaIsActive = copy?.AlphaIsActive ?? throw new ArgumentNullException(nameof(copy));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Deployment;
|
||||
using Tgstation.Server.Host.Components.Session;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.Database;
|
||||
using Tgstation.Server.Host.IO;
|
||||
|
||||
Reference in New Issue
Block a user