|
|
|
|
@@ -1,4 +1,3 @@
|
|
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
|
using MediaBrowser.Common.Implementations.IO;
|
|
|
|
|
using MediaBrowser.Common.Implementations.Logging;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
@@ -25,12 +24,7 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
|
|
|
|
|
|
public static void Main (string[] args)
|
|
|
|
|
{
|
|
|
|
|
//GetEntryAssembly is empty when running from a mkbundle package
|
|
|
|
|
#if MONOMKBUNDLE
|
|
|
|
|
var applicationPath = GetExecutablePath();
|
|
|
|
|
#else
|
|
|
|
|
var applicationPath = Assembly.GetEntryAssembly ().Location;
|
|
|
|
|
#endif
|
|
|
|
|
var applicationPath = Assembly.GetEntryAssembly().Location;
|
|
|
|
|
|
|
|
|
|
var options = new StartupOptions();
|
|
|
|
|
|
|
|
|
|
@@ -45,7 +39,7 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
|
|
|
|
|
|
var logger = _logger = logManager.GetLogger("Main");
|
|
|
|
|
|
|
|
|
|
BeginLog(logger, appPaths);
|
|
|
|
|
ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
|
|
|
|
|
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
|
|
|
|
|
|
|
|
@@ -77,40 +71,16 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
|
return new ServerApplicationPaths(programDataPath, applicationPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether this instance [can self restart].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns>
|
|
|
|
|
public static bool CanSelfRestart
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private static readonly RemoteCertificateValidationCallback IgnoreCertificates = new RemoteCertificateValidationCallback(delegate { return true; });
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether this instance can self update.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
|
|
|
|
|
public static bool CanSelfUpdate
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static RemoteCertificateValidationCallback _ignoreCertificates = new RemoteCertificateValidationCallback(delegate { return true; });
|
|
|
|
|
|
|
|
|
|
private static TaskCompletionSource<bool> _applicationTaskCompletionSource = new TaskCompletionSource<bool>();
|
|
|
|
|
private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
|
|
|
|
|
|
|
|
|
|
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)
|
|
|
|
|
{
|
|
|
|
|
SystemEvents.SessionEnding += SystemEvents_SessionEnding;
|
|
|
|
|
|
|
|
|
|
// Allow all https requests
|
|
|
|
|
ServicePointManager.ServerCertificateValidationCallback = _ignoreCertificates;
|
|
|
|
|
ServicePointManager.ServerCertificateValidationCallback = IgnoreCertificates;
|
|
|
|
|
|
|
|
|
|
var fileSystem = new CommonFileSystem(logManager.GetLogger("FileSystem"), false, true);
|
|
|
|
|
|
|
|
|
|
@@ -135,7 +105,7 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
|
task = _appHost.RunStartupTasks();
|
|
|
|
|
Task.WaitAll (task);
|
|
|
|
|
|
|
|
|
|
task = _applicationTaskCompletionSource.Task;
|
|
|
|
|
task = ApplicationTaskCompletionSource.Task;
|
|
|
|
|
|
|
|
|
|
Task.WaitAll (task);
|
|
|
|
|
}
|
|
|
|
|
@@ -153,16 +123,6 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Begins the log.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
|
|
|
|
private static void BeginLog(ILogger logger, IApplicationPaths appPaths)
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Media Browser Server started");
|
|
|
|
|
ApplicationHost.LogEnvironmentInfo(logger, appPaths);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handles the UnhandledException event of the CurrentDomain control.
|
|
|
|
|
/// </summary>
|
|
|
|
|
@@ -209,7 +169,7 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
|
|
|
|
|
|
public static void Shutdown()
|
|
|
|
|
{
|
|
|
|
|
_applicationTaskCompletionSource.SetResult (true);
|
|
|
|
|
ApplicationTaskCompletionSource.SetResult (true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Restart()
|
|
|
|
|
@@ -220,19 +180,6 @@ namespace MediaBrowser.Server.Mono
|
|
|
|
|
// Right now this method will just shutdown, but not restart
|
|
|
|
|
Shutdown ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the running process path
|
|
|
|
|
#if MONOMKBUNDLE
|
|
|
|
|
public static string GetExecutablePath()
|
|
|
|
|
{
|
|
|
|
|
var builder = new StringBuilder (8192);
|
|
|
|
|
if (Syscall.readlink("/proc/self/exe", builder) >= 0)
|
|
|
|
|
return builder.ToString ();
|
|
|
|
|
else
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class NoCheckCertificatePolicy : ICertificatePolicy
|
|
|
|
|
|