aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Mono
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Mono')
-rw-r--r--MediaBrowser.Server.Mono/ApplicationPathHelper.cs51
-rw-r--r--MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj30
-rw-r--r--MediaBrowser.Server.Mono/MonoAppHost.cs6
-rw-r--r--MediaBrowser.Server.Mono/Native/MonoFileSystem.cs2
-rw-r--r--MediaBrowser.Server.Mono/Program.cs117
-rw-r--r--MediaBrowser.Server.Mono/packages.config7
6 files changed, 109 insertions, 104 deletions
diff --git a/MediaBrowser.Server.Mono/ApplicationPathHelper.cs b/MediaBrowser.Server.Mono/ApplicationPathHelper.cs
new file mode 100644
index 000000000..c8cca40ff
--- /dev/null
+++ b/MediaBrowser.Server.Mono/ApplicationPathHelper.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Configuration;
+using System.IO;
+
+namespace MediaBrowser.Server.Mono
+{
+ public static class ApplicationPathHelper
+ {
+ /// <summary>
+ /// Gets the path to the application's ProgramDataFolder
+ /// </summary>
+ /// <returns>System.String.</returns>
+ public static string GetProgramDataPath(string applicationPath)
+ {
+ var useDebugPath = false;
+
+#if DEBUG
+ useDebugPath = true;
+#endif
+
+ var programDataPath = useDebugPath ?
+ ConfigurationManager.AppSettings["DebugProgramDataPath"] :
+ ConfigurationManager.AppSettings["ReleaseProgramDataPath"];
+
+ programDataPath = programDataPath.Replace("%ApplicationData%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
+
+ programDataPath = programDataPath
+ .Replace('/', Path.DirectorySeparatorChar)
+ .Replace('\\', Path.DirectorySeparatorChar);
+
+ // If it's a relative path, e.g. "..\"
+ if (!Path.IsPathRooted(programDataPath))
+ {
+ var path = Path.GetDirectoryName(applicationPath);
+
+ if (string.IsNullOrEmpty(path))
+ {
+ throw new ApplicationException("Unable to determine running assembly location");
+ }
+
+ programDataPath = Path.Combine(path, programDataPath);
+
+ programDataPath = Path.GetFullPath(programDataPath);
+ }
+
+ Directory.CreateDirectory(programDataPath);
+
+ return programDataPath;
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
index df98c6584..d2ce0b40d 100644
--- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
+++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
@@ -51,10 +51,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll</HintPath>
</Reference>
- <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
- <HintPath>..\packages\NLog.4.4.11\lib\net45\NLog.dll</HintPath>
- <Private>True</Private>
- </Reference>
<Reference Include="ServiceStack.Text, Version=4.5.8.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll</HintPath>
<Private>True</Private>
@@ -67,16 +63,13 @@
<HintPath>..\packages\SimpleInjector.4.0.8\lib\net45\SimpleInjector.dll</HintPath>
</Reference>
<Reference Include="SkiaSharp, Version=1.58.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
- <HintPath>..\packages\SkiaSharp.1.58.0\lib\net45\SkiaSharp.dll</HintPath>
- <Private>True</Private>
+ <HintPath>..\packages\SkiaSharp.1.58.1\lib\net45\SkiaSharp.dll</HintPath>
</Reference>
<Reference Include="SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
- <HintPath>..\packages\SQLitePCLRaw.core.1.1.7\lib\net45\SQLitePCLRaw.core.dll</HintPath>
- <Private>True</Private>
+ <HintPath>..\packages\SQLitePCLRaw.core.1.1.8\lib\net45\SQLitePCLRaw.core.dll</HintPath>
</Reference>
<Reference Include="SQLitePCLRaw.provider.sqlite3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=62684c7b4f184e3f, processorArchitecture=MSIL">
- <HintPath>..\packages\SQLitePCLRaw.provider.sqlite3.net45.1.1.7\lib\net45\SQLitePCLRaw.provider.sqlite3.dll</HintPath>
- <Private>True</Private>
+ <HintPath>..\packages\SQLitePCLRaw.provider.sqlite3.net45.1.1.8\lib\net45\SQLitePCLRaw.provider.sqlite3.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="MediaBrowser.IsoMounting.Linux">
@@ -92,6 +85,7 @@
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
</Compile>
+ <Compile Include="ApplicationPathHelper.cs" />
<Compile Include="ImageEncoderHelper.cs" />
<Compile Include="MonoAppHost.cs" />
<Compile Include="Native\MonoFileSystem.cs" />
@@ -109,10 +103,6 @@
<Project>{713f42b5-878e-499d-a878-e4c652b1d5e8}</Project>
<Name>DvdLib</Name>
</ProjectReference>
- <ProjectReference Include="..\Emby.Common.Implementations\Emby.Common.Implementations.csproj">
- <Project>{1e37a338-9f57-4b70-bd6d-bb9c591e319b}</Project>
- <Name>Emby.Common.Implementations</Name>
- </ProjectReference>
<ProjectReference Include="..\Emby.Dlna\Emby.Dlna.csproj">
<Project>{805844ab-e92f-45e6-9d99-4f6d48d129a5}</Project>
<Name>Emby.Dlna</Name>
@@ -133,10 +123,6 @@
<Project>{89ab4548-770d-41fd-a891-8daff44f452c}</Project>
<Name>Emby.Photos</Name>
</ProjectReference>
- <ProjectReference Include="..\Emby.Server.Core\Emby.Server.Core.csproj">
- <Project>{776b9f0c-5195-45e3-9a36-1cc1f0d8e0b0}</Project>
- <Name>Emby.Server.Core</Name>
- </ProjectReference>
<ProjectReference Include="..\Emby.Server.Implementations\Emby.Server.Implementations.csproj">
<Project>{e383961b-9356-4d5d-8233-9a1079d03055}</Project>
<Name>Emby.Server.Implementations</Name>
@@ -145,10 +131,6 @@
<Project>{5624B7B5-B5A7-41D8-9F10-CC5611109619}</Project>
<Name>MediaBrowser.WebDashboard</Name>
</ProjectReference>
- <ProjectReference Include="..\MediaBrowser.Server.Implementations\MediaBrowser.Server.Implementations.csproj">
- <Project>{2E781478-814D-4A48-9D80-BFF206441A65}</Project>
- <Name>MediaBrowser.Server.Implementations</Name>
- </ProjectReference>
<ProjectReference Include="..\MediaBrowser.Providers\MediaBrowser.Providers.csproj">
<Project>{442B5058-DCAF-4263-BB6A-F21E31120A1B}</Project>
<Name>MediaBrowser.Providers</Name>
@@ -169,10 +151,6 @@
<Project>{4FD51AC5-2C16-4308-A993-C3A84F3B4582}</Project>
<Name>MediaBrowser.Api</Name>
</ProjectReference>
- <ProjectReference Include="..\MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj">
- <Project>{0BD82FA6-EB8A-4452-8AF5-74F9C3849451}</Project>
- <Name>MediaBrowser.MediaEncoding</Name>
- </ProjectReference>
<ProjectReference Include="..\MediaBrowser.LocalMetadata\MediaBrowser.LocalMetadata.csproj">
<Project>{7EF9F3E0-697D-42F3-A08F-19DEB5F84392}</Project>
<Name>MediaBrowser.LocalMetadata</Name>
diff --git a/MediaBrowser.Server.Mono/MonoAppHost.cs b/MediaBrowser.Server.Mono/MonoAppHost.cs
index 1153d0f7d..ded7bb5f3 100644
--- a/MediaBrowser.Server.Mono/MonoAppHost.cs
+++ b/MediaBrowser.Server.Mono/MonoAppHost.cs
@@ -12,14 +12,12 @@ using MediaBrowser.IsoMounter;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;
-using MediaBrowser.Model.Updates;
-using MediaBrowser.Server.Startup.Common;
namespace MediaBrowser.Server.Mono
{
public class MonoAppHost : ApplicationHost
{
- public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string, string> certificateGenerator, Func<string> defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
+ public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, networkManager)
{
}
@@ -44,7 +42,7 @@ namespace MediaBrowser.Server.Mono
protected override void RestartInternal()
{
- MainClass.Restart(StartupOptions);
+ MainClass.Restart();
}
protected override List<Assembly> GetAssembliesWithPartsInternal()
diff --git a/MediaBrowser.Server.Mono/Native/MonoFileSystem.cs b/MediaBrowser.Server.Mono/Native/MonoFileSystem.cs
index 91c064efe..e6b77991c 100644
--- a/MediaBrowser.Server.Mono/Native/MonoFileSystem.cs
+++ b/MediaBrowser.Server.Mono/Native/MonoFileSystem.cs
@@ -1,4 +1,4 @@
-using Emby.Common.Implementations.IO;
+using Emby.Server.Implementations.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;
using Mono.Unix.Native;
diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs
index 0a70c446f..98ad8bb02 100644
--- a/MediaBrowser.Server.Mono/Program.cs
+++ b/MediaBrowser.Server.Mono/Program.cs
@@ -11,20 +11,16 @@ using System.Net.Security;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
-using Emby.Common.Implementations.EnvironmentInfo;
-using Emby.Common.Implementations.Logging;
-using Emby.Common.Implementations.Networking;
using Emby.Server.Core.Cryptography;
using Emby.Server.Core;
-using Emby.Server.Core.IO;
-using Emby.Server.Core.Logging;
using Emby.Server.Implementations;
+using Emby.Server.Implementations.EnvironmentInfo;
using Emby.Server.Implementations.IO;
using Emby.Server.Implementations.Logging;
+using Emby.Server.Implementations.Networking;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.System;
using Mono.Unix.Native;
-using NLog;
using ILogger = MediaBrowser.Model.Logging.ILogger;
using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate;
@@ -37,6 +33,9 @@ namespace MediaBrowser.Server.Mono
private static ILogger _logger;
private static IFileSystem FileSystem;
+ private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
+ private static bool _restartOnShutdown;
+
public static void Main(string[] args)
{
var applicationPath = Assembly.GetEntryAssembly().Location;
@@ -51,25 +50,31 @@ namespace MediaBrowser.Server.Mono
var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath);
- var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
- logManager.ReloadLogger(LogSeverity.Info);
- logManager.AddConsoleOutput();
+ using (var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server"))
+ {
+ logManager.ReloadLogger(LogSeverity.Info);
+ logManager.AddConsoleOutput();
- var logger = _logger = logManager.GetLogger("Main");
+ var logger = _logger = logManager.GetLogger("Main");
- ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
-
- AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+ ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
- try
- {
- RunApplication(appPaths, logManager, options);
- }
- finally
- {
- logger.Info("Shutting down");
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
- _appHost.Dispose();
+ try
+ {
+ RunApplication(appPaths, logManager, options);
+ }
+ finally
+ {
+ _logger.Info("Disposing app host");
+ _appHost.Dispose();
+
+ if (_restartOnShutdown)
+ {
+ StartNewInstance(options);
+ }
+ }
}
}
@@ -87,13 +92,9 @@ namespace MediaBrowser.Server.Mono
var appFolderPath = Path.GetDirectoryName(applicationPath);
- Action<string> createDirectoryFn = s => Directory.CreateDirectory(s);
-
- return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath), createDirectoryFn);
+ return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath));
}
- private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
-
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)
{
// Allow all https requests
@@ -115,11 +116,8 @@ namespace MediaBrowser.Server.Mono
"emby.mono.zip",
environmentInfo,
imageEncoder,
- new Startup.Common.SystemEvents(logManager.GetLogger("SystemEvents")),
- new MemoryStreamProvider(),
- new NetworkManager(logManager.GetLogger("NetworkManager")),
- GenerateCertificate,
- () => Environment.UserName);
+ new SystemEvents(logManager.GetLogger("SystemEvents")),
+ new NetworkManager(logManager.GetLogger("NetworkManager")));
if (options.ContainsOption("-v"))
{
@@ -144,11 +142,6 @@ namespace MediaBrowser.Server.Mono
Task.WaitAll(task);
}
- private static void GenerateCertificate(string certPath, string certHost, string certPassword)
- {
- CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, certPassword, _logger);
- }
-
private static MonoEnvironmentInfo GetEnvironmentInfo()
{
var info = new MonoEnvironmentInfo();
@@ -159,39 +152,38 @@ namespace MediaBrowser.Server.Mono
if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))
{
- //info.OperatingSystem = Startup.Common.OperatingSystem.Osx;
+ info.OperatingSystem = Model.System.OperatingSystem.OSX;
}
else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))
{
- //info.OperatingSystem = Startup.Common.OperatingSystem.Linux;
+ info.OperatingSystem = Model.System.OperatingSystem.Linux;
}
else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
{
- //info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;
- info.IsBsd = true;
+ info.OperatingSystem = Model.System.OperatingSystem.BSD;
}
var archX86 = new Regex("(i|I)[3-6]86");
if (archX86.IsMatch(uname.machine))
{
- info.CustomArchitecture = Architecture.X86;
+ info.SystemArchitecture = Architecture.X86;
}
else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
{
- info.CustomArchitecture = Architecture.X64;
+ info.SystemArchitecture = Architecture.X64;
}
else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
{
- info.CustomArchitecture = Architecture.Arm;
+ info.SystemArchitecture = Architecture.Arm;
}
else if (System.Environment.Is64BitOperatingSystem)
{
- info.CustomArchitecture = Architecture.X64;
+ info.SystemArchitecture = Architecture.X64;
}
else
{
- info.CustomArchitecture = Architecture.X86;
+ info.SystemArchitecture = Architecture.X86;
}
return info;
@@ -258,11 +250,15 @@ namespace MediaBrowser.Server.Mono
ApplicationTaskCompletionSource.SetResult(true);
}
- public static void Restart(StartupOptions startupOptions)
+ public static void Restart()
{
- _logger.Info("Disposing app host");
- _appHost.Dispose();
+ _restartOnShutdown = true;
+
+ Shutdown();
+ }
+ private static void StartNewInstance(StartupOptions startupOptions)
+ {
_logger.Info("Starting new instance");
string module = startupOptions.GetOption("-restartpath");
@@ -275,19 +271,17 @@ namespace MediaBrowser.Server.Mono
if (!startupOptions.ContainsOption("-restartargs"))
{
var args = Environment.GetCommandLineArgs()
- .Skip(1)
- .Select(NormalizeCommandLineArgument);
+ .Skip(1)
+ .Select(NormalizeCommandLineArgument)
+ .ToArray();
- commandLineArgsString = string.Join(" ", args.ToArray());
+ commandLineArgsString = string.Join(" ", args);
}
_logger.Info("Executable: {0}", module);
_logger.Info("Arguments: {0}", commandLineArgsString);
Process.Start(module, commandLineArgsString);
-
- _logger.Info("Calling Environment.Exit");
- Environment.Exit(0);
}
private static string NormalizeCommandLineArgument(string arg)
@@ -311,24 +305,9 @@ namespace MediaBrowser.Server.Mono
public class MonoEnvironmentInfo : EnvironmentInfo
{
- public bool IsBsd { get; set; }
-
public override string GetUserId()
{
return Syscall.getuid().ToString(CultureInfo.InvariantCulture);
}
-
- public override Model.System.OperatingSystem OperatingSystem
- {
- get
- {
- if (IsBsd)
- {
- return Model.System.OperatingSystem.BSD;
- }
-
- return base.OperatingSystem;
- }
- }
}
}
diff --git a/MediaBrowser.Server.Mono/packages.config b/MediaBrowser.Server.Mono/packages.config
index dcc477e9a..cff873f1f 100644
--- a/MediaBrowser.Server.Mono/packages.config
+++ b/MediaBrowser.Server.Mono/packages.config
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Mono.Posix" version="4.0.0.0" targetFramework="net45" />
- <package id="NLog" version="4.4.11" targetFramework="net46" />
<package id="ServiceStack.Text" version="4.5.8" targetFramework="net46" />
<package id="SharpCompress" version="0.14.0" targetFramework="net46" />
<package id="SimpleInjector" version="4.0.8" targetFramework="net46" />
- <package id="SkiaSharp" version="1.58.0" targetFramework="net46" />
- <package id="SQLitePCLRaw.core" version="1.1.7" targetFramework="net46" />
- <package id="SQLitePCLRaw.provider.sqlite3.net45" version="1.1.7" targetFramework="net46" />
+ <package id="SkiaSharp" version="1.58.1" targetFramework="net46" />
+ <package id="SQLitePCLRaw.core" version="1.1.8" targetFramework="net46" />
+ <package id="SQLitePCLRaw.provider.sqlite3.net45" version="1.1.8" targetFramework="net46" />
</packages> \ No newline at end of file