diff --git a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs index 3552149c3c..07954e5a88 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs @@ -22,7 +22,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// A that, instead of killing servers for updates, uses the wonders of filesystem links to swap out changes without killing the server process. /// - class AdvancedWatchdog : BasicWatchdog + abstract class AdvancedWatchdog : BasicWatchdog { /// /// The for . @@ -125,7 +125,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override async Task DisposeAndNullControllersImpl() + protected sealed override async Task DisposeAndNullControllersImpl() { await base.DisposeAndNullControllersImpl(); @@ -138,7 +138,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override async Task HandleNormalReboot(CancellationToken cancellationToken) + protected sealed override async Task HandleNormalReboot(CancellationToken cancellationToken) { if (pendingSwappable != null) { @@ -231,7 +231,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override async Task HandleNewDmbAvailable(CancellationToken cancellationToken) + protected sealed override async Task HandleNewDmbAvailable(CancellationToken cancellationToken) { IDmbProvider compileJobProvider = DmbFactory.LockNextDmb(1); bool canSeamlesslySwap = true; @@ -317,18 +317,14 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The for the operation. /// A representing the running operation. - protected virtual async Task ApplyInitialDmb(CancellationToken cancellationToken) - { - Server.ReattachInformation.InitialDmb = await DmbFactory.FromCompileJob(Server.CompileJob, cancellationToken); - } + protected abstract Task ApplyInitialDmb(CancellationToken cancellationToken); /// /// Create a for a given . /// /// The to create a for. /// A new . - protected virtual SwappableDmbProvider CreateSwappableDmbProvider(IDmbProvider dmbProvider) - => new SwappableDmbProvider(dmbProvider, GameIOManager, SymlinkFactory); + protected abstract SwappableDmbProvider CreateSwappableDmbProvider(IDmbProvider dmbProvider); /// protected override async Task SessionStartupPersist(CancellationToken cancellationToken) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs new file mode 100644 index 0000000000..917bafa134 --- /dev/null +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs @@ -0,0 +1,90 @@ +using System.Threading; +using System.Threading.Tasks; + +using Microsoft.Extensions.Logging; + +using Tgstation.Server.Api.Models.Internal; +using Tgstation.Server.Host.Components.Chat; +using Tgstation.Server.Host.Components.Deployment; +using Tgstation.Server.Host.Components.Deployment.Remote; +using Tgstation.Server.Host.Components.Events; +using Tgstation.Server.Host.Components.Session; +using Tgstation.Server.Host.Core; +using Tgstation.Server.Host.IO; +using Tgstation.Server.Host.Jobs; +using Tgstation.Server.Host.Utils; + +namespace Tgstation.Server.Host.Components.Watchdog +{ + /// + /// A variant of the that works on Windows systems. + /// + sealed class WindowsWatchdog : AdvancedWatchdog + { + /// + /// Initializes a new instance of the class. + /// + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The pointing to the game directory for the .. + /// The for the . + /// The for the . + /// The for the . + /// The for the . + /// The autostart value for the . + public WindowsWatchdog( + IChatManager chat, + ISessionControllerFactory sessionControllerFactory, + IDmbFactory dmbFactory, + ISessionPersistor sessionPersistor, + IJobManager jobManager, + IServerControl serverControl, + IAsyncDelayer asyncDelayer, + IIOManager diagnosticsIOManager, + IEventConsumer eventConsumer, + IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory, + IIOManager gameIOManager, + ISymlinkFactory symlinkFactory, + ILogger logger, + DreamDaemonLaunchParameters initialLaunchParameters, + Api.Models.Instance instance, + bool autoStart) + : base( + chat, + sessionControllerFactory, + dmbFactory, + sessionPersistor, + jobManager, + serverControl, + asyncDelayer, + diagnosticsIOManager, + eventConsumer, + remoteDeploymentManagerFactory, + gameIOManager, + symlinkFactory, + logger, + initialLaunchParameters, + instance, + autoStart) + { + } + + /// + protected override async Task ApplyInitialDmb(CancellationToken cancellationToken) + { + Server.ReattachInformation.InitialDmb = await DmbFactory.FromCompileJob(Server.CompileJob, cancellationToken); + } + + /// + protected override SwappableDmbProvider CreateSwappableDmbProvider(IDmbProvider dmbProvider) + => new SwappableDmbProvider(dmbProvider, GameIOManager, SymlinkFactory); + } +} diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs index fd7bdfe9b2..4cbe20577e 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs @@ -78,7 +78,7 @@ namespace Tgstation.Server.Host.Components.Watchdog remoteDeploymentManagerFactory, gameIOManager, SymlinkFactory, - LoggerFactory.CreateLogger(), + LoggerFactory.CreateLogger(), settings, instance, settings.AutoStart ?? throw new ArgumentNullException(nameof(settings)));