From da895ae65b0239e36b4542ed71a76cde759e757b Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 18 May 2021 19:30:07 +0200 Subject: [PATCH] Added RestartAsync to IRuntime instead of cancellation token --- src/Umbraco.Core/Services/IRuntime.cs | 3 ++- src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs | 9 +++++++-- .../Install/InstallApiController.cs | 3 +-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Services/IRuntime.cs b/src/Umbraco.Core/Services/IRuntime.cs index 3455835c8e..a28ebe7a0d 100644 --- a/src/Umbraco.Core/Services/IRuntime.cs +++ b/src/Umbraco.Core/Services/IRuntime.cs @@ -1,4 +1,5 @@ using System.Threading; +using System.Threading.Tasks; using Microsoft.Extensions.Hosting; namespace Umbraco.Cms.Core.Services @@ -13,6 +14,6 @@ namespace Umbraco.Cms.Core.Services /// IRuntimeState State { get; } - CancellationToken CancellationToken { get; } + Task RestartAsync(); } } diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs index b198b88f59..3f5e7c80bf 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs @@ -31,6 +31,7 @@ namespace Umbraco.Cms.Infrastructure.Runtime private readonly IHostingEnvironment _hostingEnvironment; private readonly DatabaseBuilder _databaseBuilder; private readonly IUmbracoVersion _umbracoVersion; + private CancellationToken _cancellationToken; /// /// Initializes a new instance of the class. @@ -66,12 +67,16 @@ namespace Umbraco.Cms.Infrastructure.Runtime /// Gets the state of the Umbraco runtime. /// public IRuntimeState State { get; } - public CancellationToken CancellationToken { get; private set; } + public async Task RestartAsync() + { + await StopAsync(_cancellationToken); + await StartAsync(_cancellationToken); + } /// public async Task StartAsync(CancellationToken cancellationToken) { - CancellationToken = cancellationToken; + _cancellationToken = cancellationToken; StaticApplicationLogging.Initialize(_loggerFactory); AppDomain.CurrentDomain.UnhandledException += (_, args) => diff --git a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs index bbdd183d90..9d97883bba 100644 --- a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs @@ -100,8 +100,7 @@ namespace Umbraco.Cms.Web.BackOffice.Install public async Task CompleteInstall() { - await _runtime.StopAsync(_runtime.CancellationToken); - await _runtime.StartAsync(_runtime.CancellationToken); + await _runtime.RestartAsync(); var identityUser = await _backOfficeUserManager.FindByIdAsync(Core.Constants.Security.SuperUserIdAsString); _backOfficeSignInManager.SignInAsync(identityUser, false);