mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-20 22:50:35 +01:00
added a shutdown api method, font size fix and other decouplings
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
@@ -29,6 +30,11 @@ namespace MediaBrowser.Api
|
||||
{
|
||||
}
|
||||
|
||||
[Route("/System/Shutdown", "POST")]
|
||||
public class ShutdownApplication
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetConfiguration
|
||||
/// </summary>
|
||||
@@ -61,19 +67,30 @@ namespace MediaBrowser.Api
|
||||
/// </summary>
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
|
||||
/// <summary>
|
||||
/// The _app host
|
||||
/// </summary>
|
||||
private readonly IApplicationHost _appHost;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SystemService" /> class.
|
||||
/// </summary>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="appHost">The app host.</param>
|
||||
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
|
||||
public SystemService(IJsonSerializer jsonSerializer)
|
||||
public SystemService(IJsonSerializer jsonSerializer, IApplicationHost appHost)
|
||||
: base()
|
||||
{
|
||||
if (jsonSerializer == null)
|
||||
{
|
||||
throw new ArgumentNullException("jsonSerializer");
|
||||
}
|
||||
if (appHost == null)
|
||||
{
|
||||
throw new ArgumentNullException("appHost");
|
||||
}
|
||||
|
||||
_appHost = appHost;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
}
|
||||
|
||||
@@ -118,6 +135,19 @@ namespace MediaBrowser.Api
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
public void Post(ShutdownApplication request)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(100);
|
||||
_appHost.Shutdown();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the specified configuraiton.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -27,18 +26,20 @@ namespace MediaBrowser.Api.WebSocket
|
||||
/// <summary>
|
||||
/// The _kernel
|
||||
/// </summary>
|
||||
private readonly IApplicationHost _appHost;
|
||||
private readonly IKernel _kernel;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LogFileWebSocketListener" /> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
public LogFileWebSocketListener(ILogger logger, Kernel kernel)
|
||||
public LogFileWebSocketListener(ILogger logger, IApplicationHost host, IKernel kernel)
|
||||
: base(logger)
|
||||
{
|
||||
_appHost = host;
|
||||
_kernel = kernel;
|
||||
_kernel.LoggerLoaded += kernel_LoggerLoaded;
|
||||
kernel.LoggerLoaded += kernel_LoggerLoaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -48,9 +49,9 @@ namespace MediaBrowser.Api.WebSocket
|
||||
/// <returns>IEnumerable{System.String}.</returns>
|
||||
protected override async Task<IEnumerable<string>> GetDataToSend(LogFileWebSocketState state)
|
||||
{
|
||||
if (!string.Equals(_kernel.LogFilePath, state.LastLogFilePath))
|
||||
if (!string.Equals(_appHost.LogFilePath, state.LastLogFilePath))
|
||||
{
|
||||
state.LastLogFilePath = _kernel.LogFilePath;
|
||||
state.LastLogFilePath = _appHost.LogFilePath;
|
||||
state.StartLine = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user