diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 86721ace61..e2d2719e5d 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -101,6 +101,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Prometheus.DotNetRuntime;
using static MediaBrowser.Controller.Extensions.ConfigurationExtensions;
@@ -850,6 +851,24 @@ namespace Emby.Server.Implementations
}
}
+ ///
+ public void Restart()
+ {
+ ShouldRestart = true;
+ Shutdown();
+ }
+
+ ///
+ public void Shutdown()
+ {
+ Task.Run(async () =>
+ {
+ await Task.Delay(100).ConfigureAwait(false);
+ IsShuttingDown = true;
+ Resolve().StopApplication();
+ });
+ }
+
///
/// Gets the composable part assemblies.
///
diff --git a/Jellyfin.Api/Controllers/SystemController.cs b/Jellyfin.Api/Controllers/SystemController.cs
index 4cc0f0ced4..42ac4a9b4b 100644
--- a/Jellyfin.Api/Controllers/SystemController.cs
+++ b/Jellyfin.Api/Controllers/SystemController.cs
@@ -4,7 +4,6 @@ using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Net.Mime;
-using System.Threading.Tasks;
using Jellyfin.Api.Attributes;
using Jellyfin.Api.Constants;
using MediaBrowser.Common.Configuration;
@@ -18,7 +17,6 @@ using MediaBrowser.Model.System;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Jellyfin.Api.Controllers;
@@ -33,7 +31,6 @@ public class SystemController : BaseJellyfinApiController
private readonly IFileSystem _fileSystem;
private readonly INetworkManager _network;
private readonly ILogger _logger;
- private readonly IHostApplicationLifetime _hostApplicationLifetime;
///
/// Initializes a new instance of the class.
@@ -43,21 +40,18 @@ public class SystemController : BaseJellyfinApiController
/// Instance of interface.
/// Instance of interface.
/// Instance of interface.
- /// Instance of interface.
public SystemController(
IServerConfigurationManager serverConfigurationManager,
IServerApplicationHost appHost,
IFileSystem fileSystem,
INetworkManager network,
- ILogger logger,
- IHostApplicationLifetime hostApplicationLifetime)
+ ILogger logger)
{
_appPaths = serverConfigurationManager.ApplicationPaths;
_appHost = appHost;
_fileSystem = fileSystem;
_network = network;
_logger = logger;
- _hostApplicationLifetime = hostApplicationLifetime;
}
///
@@ -112,13 +106,7 @@ public class SystemController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public ActionResult RestartApplication()
{
- Task.Run(async () =>
- {
- await Task.Delay(100).ConfigureAwait(false);
- _appHost.ShouldRestart = true;
- _appHost.IsShuttingDown = true;
- _hostApplicationLifetime.StopApplication();
- });
+ _appHost.Restart();
return NoContent();
}
@@ -134,12 +122,7 @@ public class SystemController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public ActionResult ShutdownApplication()
{
- Task.Run(async () =>
- {
- await Task.Delay(100).ConfigureAwait(false);
- _appHost.IsShuttingDown = true;
- _hostApplicationLifetime.StopApplication();
- });
+ _appHost.Shutdown();
return NoContent();
}
diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs
index c1ea6e87cc..5985d3dd82 100644
--- a/MediaBrowser.Common/IApplicationHost.cs
+++ b/MediaBrowser.Common/IApplicationHost.cs
@@ -41,15 +41,15 @@ namespace MediaBrowser.Common
bool HasPendingRestart { get; }
///
- /// Gets or sets a value indicating whether this instance is currently shutting down.
+ /// Gets a value indicating whether this instance is currently shutting down.
///
/// true if this instance is shutting down; otherwise, false.
- bool IsShuttingDown { get; set; }
+ bool IsShuttingDown { get; }
///
- /// Gets or sets a value indicating whether the application should restart.
+ /// Gets a value indicating whether the application should restart.
///
- bool ShouldRestart { get; set; }
+ bool ShouldRestart { get; }
///
/// Gets the application version.
@@ -91,6 +91,11 @@ namespace MediaBrowser.Common
///
void NotifyPendingRestart();
+ ///
+ /// Restarts this instance.
+ ///
+ void Restart();
+
///
/// Gets the exports.
///
@@ -122,6 +127,11 @@ namespace MediaBrowser.Common
/// ``0.
T Resolve();
+ ///
+ /// Shuts down.
+ ///
+ void Shutdown();
+
///
/// Initializes this instance.
///