|
|
@ -12,6 +12,7 @@ using MediaBrowser.Controller;
|
|
|
|
using MediaBrowser.IsoMounter;
|
|
|
|
using MediaBrowser.IsoMounter;
|
|
|
|
using MediaBrowser.Logging.Nlog;
|
|
|
|
using MediaBrowser.Logging.Nlog;
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
|
|
|
using MediaBrowser.Model.Serialization;
|
|
|
|
using MediaBrowser.Model.Serialization;
|
|
|
|
using MediaBrowser.Model.System;
|
|
|
|
using MediaBrowser.Model.System;
|
|
|
@ -39,12 +40,6 @@ namespace MediaBrowser.ServerApplication
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class ApplicationHost : BaseApplicationHost, IApplicationHost
|
|
|
|
public class ApplicationHost : BaseApplicationHost, IApplicationHost
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Gets or sets the log file path.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <value>The log file path.</value>
|
|
|
|
|
|
|
|
public string LogFilePath { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the kernel.
|
|
|
|
/// Gets or sets the kernel.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -62,15 +57,13 @@ namespace MediaBrowser.ServerApplication
|
|
|
|
private readonly IXmlSerializer _xmlSerializer = new XmlSerializer();
|
|
|
|
private readonly IXmlSerializer _xmlSerializer = new XmlSerializer();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// The _application paths
|
|
|
|
/// Gets the server application paths.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private readonly IServerApplicationPaths _applicationPaths = new ServerApplicationPaths();
|
|
|
|
/// <value>The server application paths.</value>
|
|
|
|
|
|
|
|
protected IServerApplicationPaths ServerApplicationPaths
|
|
|
|
/// <summary>
|
|
|
|
{
|
|
|
|
/// Gets a value indicating whether this instance is first run.
|
|
|
|
get { return (IServerApplicationPaths) ApplicationPaths; }
|
|
|
|
/// </summary>
|
|
|
|
}
|
|
|
|
/// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value>
|
|
|
|
|
|
|
|
public bool IsFirstRun { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="ApplicationHost" /> class.
|
|
|
|
/// Initializes a new instance of the <see cref="ApplicationHost" /> class.
|
|
|
@ -79,21 +72,15 @@ namespace MediaBrowser.ServerApplication
|
|
|
|
public ApplicationHost()
|
|
|
|
public ApplicationHost()
|
|
|
|
: base()
|
|
|
|
: base()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IsFirstRun = !File.Exists(_applicationPaths.SystemConfigurationFilePath);
|
|
|
|
Kernel = new Kernel(this, ServerApplicationPaths, _xmlSerializer, Logger);
|
|
|
|
|
|
|
|
|
|
|
|
Logger = new NLogger("App");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DiscoverTypes();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Kernel = new Kernel(this, _applicationPaths, _xmlSerializer, Logger);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var networkManager = new NetworkManager();
|
|
|
|
var networkManager = new NetworkManager();
|
|
|
|
|
|
|
|
|
|
|
|
var serverManager = new ServerManager(this, Kernel, networkManager, _jsonSerializer, Logger);
|
|
|
|
var serverManager = new ServerManager(this, Kernel, networkManager, _jsonSerializer, Logger);
|
|
|
|
|
|
|
|
|
|
|
|
var taskManager = new TaskManager(_applicationPaths, _jsonSerializer, Logger, serverManager);
|
|
|
|
var taskManager = new TaskManager(ApplicationPaths, _jsonSerializer, Logger, serverManager);
|
|
|
|
|
|
|
|
|
|
|
|
ReloadLogger();
|
|
|
|
LogManager.ReloadLogger(Kernel.Configuration.EnableDebugLevelLogging ? LogSeverity.Debug : LogSeverity.Info);
|
|
|
|
|
|
|
|
|
|
|
|
Logger.Info("Version {0} initializing", ApplicationVersion);
|
|
|
|
Logger.Info("Version {0} initializing", ApplicationVersion);
|
|
|
|
|
|
|
|
|
|
|
@ -104,6 +91,24 @@ namespace MediaBrowser.ServerApplication
|
|
|
|
FindParts(taskManager, httpServer);
|
|
|
|
FindParts(taskManager, httpServer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Gets the application paths.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <returns>IApplicationPaths.</returns>
|
|
|
|
|
|
|
|
protected override IApplicationPaths GetApplicationPaths()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new ServerApplicationPaths();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Gets the log manager.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <returns>ILogManager.</returns>
|
|
|
|
|
|
|
|
protected override ILogManager GetLogManager()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new NlogManager(ApplicationPaths.LogDirectoryPath, "Server");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Registers resources that classes will depend on
|
|
|
|
/// Registers resources that classes will depend on
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -113,14 +118,15 @@ namespace MediaBrowser.ServerApplication
|
|
|
|
RegisterSingleInstance(Kernel);
|
|
|
|
RegisterSingleInstance(Kernel);
|
|
|
|
|
|
|
|
|
|
|
|
RegisterSingleInstance<IApplicationHost>(this);
|
|
|
|
RegisterSingleInstance<IApplicationHost>(this);
|
|
|
|
|
|
|
|
RegisterSingleInstance(LogManager);
|
|
|
|
RegisterSingleInstance(Logger);
|
|
|
|
RegisterSingleInstance(Logger);
|
|
|
|
|
|
|
|
|
|
|
|
RegisterSingleInstance(_applicationPaths);
|
|
|
|
RegisterSingleInstance(ApplicationPaths);
|
|
|
|
RegisterSingleInstance<IApplicationPaths>(_applicationPaths);
|
|
|
|
RegisterSingleInstance(ServerApplicationPaths);
|
|
|
|
RegisterSingleInstance(taskManager);
|
|
|
|
RegisterSingleInstance(taskManager);
|
|
|
|
RegisterSingleInstance<IIsoManager>(new PismoIsoManager(Logger));
|
|
|
|
RegisterSingleInstance<IIsoManager>(new PismoIsoManager(Logger));
|
|
|
|
RegisterSingleInstance<IBlurayExaminer>(new BdInfoExaminer());
|
|
|
|
RegisterSingleInstance<IBlurayExaminer>(new BdInfoExaminer());
|
|
|
|
RegisterSingleInstance<IHttpClient>(new HttpManager(_applicationPaths, Logger));
|
|
|
|
RegisterSingleInstance<IHttpClient>(new HttpManager(ApplicationPaths, Logger));
|
|
|
|
RegisterSingleInstance<IZipClient>(new DotNetZipClient());
|
|
|
|
RegisterSingleInstance<IZipClient>(new DotNetZipClient());
|
|
|
|
RegisterSingleInstance<IWebSocketServer>(() => new AlchemyServer(Logger));
|
|
|
|
RegisterSingleInstance<IWebSocketServer>(() => new AlchemyServer(Logger));
|
|
|
|
RegisterSingleInstance(_jsonSerializer);
|
|
|
|
RegisterSingleInstance(_jsonSerializer);
|
|
|
@ -147,23 +153,11 @@ namespace MediaBrowser.ServerApplication
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Restarts this instance.
|
|
|
|
/// Restarts this instance.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
|
|
|
|
|
|
public void Restart()
|
|
|
|
public void Restart()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
App.Instance.Restart();
|
|
|
|
App.Instance.Restart();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Reloads the logger.
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
|
|
|
|
|
|
public void ReloadLogger()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LogFilePath = Path.Combine(_applicationPaths.LogDirectoryPath, "Server-" + DateTime.Now.Ticks + ".log");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NlogManager.AddFileTarget(LogFilePath, Kernel.Configuration.EnableDebugLevelLogging);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets a value indicating whether this instance can self update.
|
|
|
|
/// Gets or sets a value indicating whether this instance can self update.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -204,7 +198,7 @@ namespace MediaBrowser.ServerApplication
|
|
|
|
// Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
|
|
|
|
// Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
|
|
|
|
// This will prevent the .dll file from getting locked, and allow us to replace it when needed
|
|
|
|
// This will prevent the .dll file from getting locked, and allow us to replace it when needed
|
|
|
|
foreach (var pluginAssembly in Directory
|
|
|
|
foreach (var pluginAssembly in Directory
|
|
|
|
.EnumerateFiles(_applicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly)
|
|
|
|
.EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly)
|
|
|
|
.Select(LoadAssembly).Where(a => a != null))
|
|
|
|
.Select(LoadAssembly).Where(a => a != null))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
yield return pluginAssembly;
|
|
|
|
yield return pluginAssembly;
|
|
|
|