mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-22 16:54:46 +03:00
update restart function
This commit is contained in:
@@ -11,6 +11,7 @@ using System.Net.Security;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Emby.Drawing;
|
||||
using Emby.Server.Core.Cryptography;
|
||||
using Emby.Server.Core;
|
||||
using Emby.Server.Implementations;
|
||||
@@ -18,6 +19,7 @@ using Emby.Server.Implementations.EnvironmentInfo;
|
||||
using Emby.Server.Implementations.IO;
|
||||
using Emby.Server.Implementations.Logging;
|
||||
using Emby.Server.Implementations.Networking;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.System;
|
||||
using Mono.Unix.Native;
|
||||
@@ -28,10 +30,10 @@ namespace MediaBrowser.Server.Mono
|
||||
{
|
||||
public class MainClass
|
||||
{
|
||||
private static ApplicationHost _appHost;
|
||||
|
||||
private static ILogger _logger;
|
||||
private static IFileSystem FileSystem;
|
||||
private static IServerApplicationPaths _appPaths;
|
||||
private static ILogManager _logManager;
|
||||
|
||||
private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
|
||||
private static bool _restartOnShutdown;
|
||||
@@ -49,9 +51,12 @@ namespace MediaBrowser.Server.Mono
|
||||
var customProgramDataPath = options.GetOption("-programdata");
|
||||
|
||||
var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath);
|
||||
_appPaths = appPaths;
|
||||
|
||||
using (var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server"))
|
||||
{
|
||||
_logManager = logManager;
|
||||
|
||||
logManager.ReloadLogger(LogSeverity.Info);
|
||||
logManager.AddConsoleOutput();
|
||||
|
||||
@@ -68,7 +73,6 @@ namespace MediaBrowser.Server.Mono
|
||||
finally
|
||||
{
|
||||
_logger.Info("Disposing app host");
|
||||
_appHost.Dispose();
|
||||
|
||||
if (_restartOnShutdown)
|
||||
{
|
||||
@@ -106,40 +110,41 @@ namespace MediaBrowser.Server.Mono
|
||||
|
||||
FileSystem = fileSystem;
|
||||
|
||||
var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths, environmentInfo);
|
||||
|
||||
_appHost = new MonoAppHost(appPaths,
|
||||
using (var appHost = new MonoAppHost(appPaths,
|
||||
logManager,
|
||||
options,
|
||||
fileSystem,
|
||||
new PowerManagement(),
|
||||
"emby.mono.zip",
|
||||
environmentInfo,
|
||||
imageEncoder,
|
||||
new NullImageEncoder(),
|
||||
new SystemEvents(logManager.GetLogger("SystemEvents")),
|
||||
new NetworkManager(logManager.GetLogger("NetworkManager")));
|
||||
|
||||
if (options.ContainsOption("-v"))
|
||||
new NetworkManager(logManager.GetLogger("NetworkManager"))))
|
||||
{
|
||||
Console.WriteLine(_appHost.ApplicationVersion.ToString());
|
||||
return;
|
||||
appHost.ImageProcessor.ImageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => appHost.HttpClient, appPaths, environmentInfo);
|
||||
|
||||
if (options.ContainsOption("-v"))
|
||||
{
|
||||
Console.WriteLine(appHost.ApplicationVersion.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("appHost.Init");
|
||||
|
||||
var initProgress = new Progress<double>();
|
||||
|
||||
var task = appHost.Init(initProgress);
|
||||
Task.WaitAll(task);
|
||||
|
||||
Console.WriteLine("Running startup tasks");
|
||||
|
||||
task = appHost.RunStartupTasks();
|
||||
Task.WaitAll(task);
|
||||
|
||||
task = ApplicationTaskCompletionSource.Task;
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
Console.WriteLine("appHost.Init");
|
||||
|
||||
var initProgress = new Progress<double>();
|
||||
|
||||
var task = _appHost.Init(initProgress);
|
||||
Task.WaitAll(task);
|
||||
|
||||
Console.WriteLine("Running startup tasks");
|
||||
|
||||
task = _appHost.RunStartupTasks();
|
||||
Task.WaitAll(task);
|
||||
|
||||
task = ApplicationTaskCompletionSource.Task;
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
private static MonoEnvironmentInfo GetEnvironmentInfo()
|
||||
@@ -231,7 +236,7 @@ namespace MediaBrowser.Server.Mono
|
||||
{
|
||||
var exception = (Exception)e.ExceptionObject;
|
||||
|
||||
new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager, FileSystem, new ConsoleLogger()).Log(exception);
|
||||
new UnhandledExceptionWriter(_appPaths, _logger, _logManager, FileSystem, new ConsoleLogger()).Log(exception);
|
||||
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user