diff --git a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs index 75407159ec..35326200d6 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs @@ -11,8 +11,8 @@ namespace Tgstation.Server.Host.Components.Watchdog /// Creates a /// /// The for the with - /// The initial for the + /// The initial for the /// A new - IWatchdog CreateWatchdog(IDmbFactory dmbFactory, DreamDaemonLaunchParameters launchParameters); + IWatchdog CreateWatchdog(IDmbFactory dmbFactory, DreamDaemonSettings settings); } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs index ef3688fe7a..d2a32643e2 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/Watchdog.cs @@ -78,6 +78,11 @@ namespace Tgstation.Server.Host.Components.Watchdog /// readonly long instanceId; + /// + /// If the should in + /// + readonly bool autoStart; + CancellationTokenSource monitorCts; Task monitorTask; @@ -101,7 +106,8 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The value of /// The initial value of /// The containing the value of - public Watchdog(IChat chat, ISessionControllerFactory sessionControllerFactory, IDmbFactory dmbFactory, IServerUpdater serverUpdater, ILogger logger, IReattachInfoHandler reattachInfoHandler, IDatabaseContextFactory databaseContextFactory, DreamDaemonLaunchParameters initialLaunchParameters, Models.Instance instance) + /// The value of + public Watchdog(IChat chat, ISessionControllerFactory sessionControllerFactory, IDmbFactory dmbFactory, IServerUpdater serverUpdater, ILogger logger, IReattachInfoHandler reattachInfoHandler, IDatabaseContextFactory databaseContextFactory, DreamDaemonLaunchParameters initialLaunchParameters, Models.Instance instance, bool autoStart) { this.chat = chat ?? throw new ArgumentNullException(nameof(chat)); this.sessionControllerFactory = sessionControllerFactory ?? throw new ArgumentNullException(nameof(sessionControllerFactory)); @@ -110,6 +116,7 @@ namespace Tgstation.Server.Host.Components.Watchdog this.reattachInfoHandler = reattachInfoHandler ?? throw new ArgumentNullException(nameof(reattachInfoHandler)); this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory)); instanceId = instance?.Id ?? throw new ArgumentNullException(nameof(instance)); + this.autoStart = autoStart; if (serverUpdater == null) throw new ArgumentNullException(nameof(serverUpdater)); @@ -502,7 +509,11 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - public Task StartAsync(CancellationToken cancellationToken) => LaunchNoLock(true, true, true, cancellationToken); + public async Task StartAsync(CancellationToken cancellationToken) + { + if (autoStart) + await LaunchNoLock(true, true, true, cancellationToken).ConfigureAwait(false); + } /// public async Task StopAsync(CancellationToken cancellationToken) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs index 5df22cc735..ad068c4b31 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs @@ -67,6 +67,6 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - public IWatchdog CreateWatchdog(IDmbFactory dmbFactory, DreamDaemonLaunchParameters launchParameters) => new Watchdog(chat, sessionManagerFactory, dmbFactory, serverUpdater, loggerFactory.CreateLogger(), reattachInfoHandler, databaseContextFactory, launchParameters, instance); + public IWatchdog CreateWatchdog(IDmbFactory dmbFactory, DreamDaemonSettings settings) => new Watchdog(chat, sessionManagerFactory, dmbFactory, serverUpdater, loggerFactory.CreateLogger(), reattachInfoHandler, databaseContextFactory, settings, instance, settings.AutoStart.Value); } }