diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs
index 2cedce3c5e..87626da1fc 100644
--- a/src/Tgstation.Server.Host/Core/Application.cs
+++ b/src/Tgstation.Server.Host/Core/Application.cs
@@ -1,11 +1,11 @@
-using Cyberboss.AspNetCore.AsyncInitializer;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Globalization;
@@ -34,16 +34,16 @@ namespace Tgstation.Server.Host.Core
readonly IConfiguration configuration;
///
- /// The for the
+ /// The for the
///
- readonly IHostingEnvironment hostingEnvironment;
+ readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment;
///
/// Construct an
///
/// The value of
/// The value of
- public Application(IConfiguration configuration, IHostingEnvironment hostingEnvironment)
+ public Application(IConfiguration configuration, Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment)
{
this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
this.hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
@@ -131,6 +131,10 @@ namespace Tgstation.Server.Host.Core
services.AddSingleton, PasswordHasher>();
services.AddSingleton();
services.AddSingleton();
+
+ services.AddSingleton();
+ services.AddSingleton(x => x.GetRequiredService());
+ services.AddSingleton(x => x.GetRequiredService());
}
///
@@ -144,13 +148,7 @@ namespace Tgstation.Server.Host.Core
if (hostingEnvironment.IsDevelopment())
applicationBuilder.UseDeveloperExceptionPage();
-
- applicationBuilder.UseAsyncInitialization(async (cancellationToken) =>
- {
- using (var scope = applicationBuilder.ApplicationServices.CreateScope())
- await scope.ServiceProvider.GetRequiredService().Initialize(cancellationToken).ConfigureAwait(false);
- });
-
+
applicationBuilder.UseAuthentication();
applicationBuilder.UseMvc();
}
diff --git a/src/Tgstation.Server.Host/Core/IJobManager.cs b/src/Tgstation.Server.Host/Core/IJobManager.cs
new file mode 100644
index 0000000000..13d30ad436
--- /dev/null
+++ b/src/Tgstation.Server.Host/Core/IJobManager.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Tgstation.Server.Host.Models;
+
+namespace Tgstation.Server.Host.Core
+{
+ interface IJobManager
+ {
+ ///
+ /// Registers a given and begins running it
+ ///
+ /// The
+ /// The operation to run
+ /// The for the operation
+ /// A representing a running operation
+ Task RegisterOperation(Job job, Func operation, CancellationToken cancellationToken);
+
+ ///
+ /// Wait for a given to complete
+ ///
+ /// The to wait for
+ /// The for the operation
+ /// A representing a running operation
+ Task WaitForJob(Job job, CancellationToken cancellationToken);
+
+ ///
+ /// Cancels a give
+ ///
+ /// The to cancel
+ void CancelJob(Job job);
+ }
+}
diff --git a/src/Tgstation.Server.Host/Core/JobHandler.cs b/src/Tgstation.Server.Host/Core/JobHandler.cs
new file mode 100644
index 0000000000..ab05719268
--- /dev/null
+++ b/src/Tgstation.Server.Host/Core/JobHandler.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Tgstation.Server.Host.Core
+{
+ ///
+ /// Class for pairing s with s
+ ///
+ sealed class JobHandler : IDisposable
+ {
+ ///
+ /// The being run
+ ///
+ readonly Task task;
+ ///
+ /// The for
+ ///
+ readonly CancellationTokenSource cancellationTokenSource;
+
+ ///
+ /// Construct a
+ ///
+ /// The value of
+ /// The value of
+ JobHandler(Task task, CancellationTokenSource cancellationTokenSource)
+ {
+ this.task = task;
+ this.cancellationTokenSource = cancellationTokenSource;
+ }
+
+ ///
+ public void Dispose() => cancellationTokenSource.Dispose();
+
+ ///
+ /// Wait for to complete
+ ///
+ /// The for the operation
+ /// A representing the running operation
+ public async Task Wait(CancellationToken cancellationToken)
+ {
+ TaskCompletionSource