diff --git a/src/Tgstation.Server.Host/Components/IInstanceCoreProvider.cs b/src/Tgstation.Server.Host/Components/IInstanceCoreProvider.cs
index fb50f512a8..7e6b0b8dc5 100644
--- a/src/Tgstation.Server.Host/Components/IInstanceCoreProvider.cs
+++ b/src/Tgstation.Server.Host/Components/IInstanceCoreProvider.cs
@@ -3,7 +3,7 @@
///
/// Provider for s.
///
- interface IInstanceCoreProvider
+ public interface IInstanceCoreProvider
{
///
/// Get the for a given if it's online.
diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs
index 5c53a622c3..5c001e978d 100644
--- a/src/Tgstation.Server.Host/Components/InstanceManager.cs
+++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs
@@ -431,7 +431,7 @@ namespace Tgstation.Server.Host.Components
await Task.WhenAll(instanceOnliningTasks);
- jobManager.Activate();
+ jobManager.Activate(this);
logger.LogInformation("Server ready!");
readyTcs.SetResult();
diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs
index f96b2e5670..c0b7a53c03 100644
--- a/src/Tgstation.Server.Host/Core/Application.cs
+++ b/src/Tgstation.Server.Host/Core/Application.cs
@@ -355,7 +355,6 @@ namespace Tgstation.Server.Host.Core
services.AddSingleton();
services.AddSingleton(x => x.GetRequiredService());
- services.AddSingleton(x => new Lazy(() => x.GetRequiredService()));
services.AddSingleton(x => x.GetRequiredService());
}
diff --git a/src/Tgstation.Server.Host/Jobs/IJobManager.cs b/src/Tgstation.Server.Host/Jobs/IJobManager.cs
index b9130deb4d..30a0a45cc7 100644
--- a/src/Tgstation.Server.Host/Jobs/IJobManager.cs
+++ b/src/Tgstation.Server.Host/Jobs/IJobManager.cs
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Tgstation.Server.Api.Models.Response;
+using Tgstation.Server.Host.Components;
using Tgstation.Server.Host.Models;
namespace Tgstation.Server.Host.Jobs
@@ -50,6 +51,7 @@ namespace Tgstation.Server.Host.Jobs
///
/// Activate the .
///
- void Activate();
+ /// The for the .
+ void Activate(IInstanceCoreProvider instanceCoreProvider);
}
}
diff --git a/src/Tgstation.Server.Host/Jobs/JobManager.cs b/src/Tgstation.Server.Host/Jobs/JobManager.cs
index f40bdaa13a..73b66dbcc4 100644
--- a/src/Tgstation.Server.Host/Jobs/JobManager.cs
+++ b/src/Tgstation.Server.Host/Jobs/JobManager.cs
@@ -33,20 +33,15 @@ namespace Tgstation.Server.Host.Jobs
///
readonly ILogger logger;
- ///
- /// The for the .
- ///
- readonly Lazy instanceCoreProvider;
-
///
/// of s to running s.
///
readonly Dictionary jobs;
///
- /// to delay starting jobs until the server is ready.
+ /// to delay starting jobs until the server is ready.
///
- readonly TaskCompletionSource activationTcs;
+ readonly TaskCompletionSource activationTcs;
///
/// for various operations.
@@ -62,21 +57,18 @@ namespace Tgstation.Server.Host.Jobs
/// Initializes a new instance of the class.
///
/// The value of .
- /// The value of .
/// The value of .
/// The value of .
public JobManager(
IDatabaseContextFactory databaseContextFactory,
- Lazy instanceCoreProvider,
ILoggerFactory loggerFactory,
ILogger logger)
{
this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
- this.instanceCoreProvider = instanceCoreProvider ?? throw new ArgumentNullException(nameof(instanceCoreProvider));
this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
jobs = new Dictionary();
- activationTcs = new TaskCompletionSource();
+ activationTcs = new TaskCompletionSource();
synchronizationLock = new object();
addCancelLock = new object();
}
@@ -265,10 +257,13 @@ namespace Tgstation.Server.Host.Jobs
}
///
- public void Activate()
+ public void Activate(IInstanceCoreProvider instanceCoreProvider)
{
+ if (instanceCoreProvider == null)
+ throw new ArgumentNullException(nameof(instanceCoreProvider));
+
logger.LogTrace("Activating job manager...");
- activationTcs.SetResult();
+ activationTcs.SetResult(instanceCoreProvider);
}
///
@@ -322,11 +317,11 @@ namespace Tgstation.Server.Host.Jobs
}
}
- await activationTcs.Task.WithToken(cancellationToken);
+ var instanceCoreProvider = await activationTcs.Task.WithToken(cancellationToken);
logger.LogTrace("Starting job...");
await operation(
- instanceCoreProvider.Value.GetInstance(oldJob.Instance),
+ instanceCoreProvider.GetInstance(oldJob.Instance),
databaseContextFactory,
job,
new JobProgressReporter(