aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/SystemController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Api/Controllers/SystemController.cs')
-rw-r--r--Jellyfin.Api/Controllers/SystemController.cs14
1 files changed, 11 insertions, 3 deletions
diff --git a/Jellyfin.Api/Controllers/SystemController.cs b/Jellyfin.Api/Controllers/SystemController.cs
index a29790961..4cc0f0ced 100644
--- a/Jellyfin.Api/Controllers/SystemController.cs
+++ b/Jellyfin.Api/Controllers/SystemController.cs
@@ -18,6 +18,7 @@ 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;
@@ -32,6 +33,7 @@ public class SystemController : BaseJellyfinApiController
private readonly IFileSystem _fileSystem;
private readonly INetworkManager _network;
private readonly ILogger<SystemController> _logger;
+ private readonly IHostApplicationLifetime _hostApplicationLifetime;
/// <summary>
/// Initializes a new instance of the <see cref="SystemController"/> class.
@@ -41,18 +43,21 @@ public class SystemController : BaseJellyfinApiController
/// <param name="fileSystem">Instance of <see cref="IFileSystem"/> interface.</param>
/// <param name="network">Instance of <see cref="INetworkManager"/> interface.</param>
/// <param name="logger">Instance of <see cref="ILogger{SystemController}"/> interface.</param>
+ /// <param name="hostApplicationLifetime">Instance of <see cref="IHostApplicationLifetime"/> interface.</param>
public SystemController(
IServerConfigurationManager serverConfigurationManager,
IServerApplicationHost appHost,
IFileSystem fileSystem,
INetworkManager network,
- ILogger<SystemController> logger)
+ ILogger<SystemController> logger,
+ IHostApplicationLifetime hostApplicationLifetime)
{
_appPaths = serverConfigurationManager.ApplicationPaths;
_appHost = appHost;
_fileSystem = fileSystem;
_network = network;
_logger = logger;
+ _hostApplicationLifetime = hostApplicationLifetime;
}
/// <summary>
@@ -110,7 +115,9 @@ public class SystemController : BaseJellyfinApiController
Task.Run(async () =>
{
await Task.Delay(100).ConfigureAwait(false);
- _appHost.Restart();
+ _appHost.ShouldRestart = true;
+ _appHost.IsShuttingDown = true;
+ _hostApplicationLifetime.StopApplication();
});
return NoContent();
}
@@ -130,7 +137,8 @@ public class SystemController : BaseJellyfinApiController
Task.Run(async () =>
{
await Task.Delay(100).ConfigureAwait(false);
- await _appHost.Shutdown().ConfigureAwait(false);
+ _appHost.IsShuttingDown = true;
+ _hostApplicationLifetime.StopApplication();
});
return NoContent();
}