Added RestartAsync to IRuntime instead of cancellation token

This commit is contained in:
Bjarke Berg
2021-05-18 19:30:07 +02:00
parent 4c78702da0
commit da895ae65b
3 changed files with 10 additions and 5 deletions

View File

@@ -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
/// </summary>
IRuntimeState State { get; }
CancellationToken CancellationToken { get; }
Task RestartAsync();
}
}

View File

@@ -31,6 +31,7 @@ namespace Umbraco.Cms.Infrastructure.Runtime
private readonly IHostingEnvironment _hostingEnvironment;
private readonly DatabaseBuilder _databaseBuilder;
private readonly IUmbracoVersion _umbracoVersion;
private CancellationToken _cancellationToken;
/// <summary>
/// Initializes a new instance of the <see cref="CoreRuntime"/> class.
@@ -66,12 +67,16 @@ namespace Umbraco.Cms.Infrastructure.Runtime
/// Gets the state of the Umbraco runtime.
/// </summary>
public IRuntimeState State { get; }
public CancellationToken CancellationToken { get; private set; }
public async Task RestartAsync()
{
await StopAsync(_cancellationToken);
await StartAsync(_cancellationToken);
}
/// <inheritdoc/>
public async Task StartAsync(CancellationToken cancellationToken)
{
CancellationToken = cancellationToken;
_cancellationToken = cancellationToken;
StaticApplicationLogging.Initialize(_loggerFactory);
AppDomain.CurrentDomain.UnhandledException += (_, args) =>

View File

@@ -100,8 +100,7 @@ namespace Umbraco.Cms.Web.BackOffice.Install
public async Task<ActionResult> 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);