aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-11-14 02:29:42 -0500
committerGitHub <noreply@github.com>2016-11-14 02:29:42 -0500
commit54d3c2eed767b6d030961f9a75216c447f94abef (patch)
tree1855731242b35ffbed16beb1c96de1e6442a797e /src
parente8379b865c301cb8ab65eb5b883c44abdbedcf79 (diff)
parent43c69713835afee3d27ced041e5f96ec36fa0ce3 (diff)
Merge pull request #2288 from MediaBrowser/dev
Dev
Diffstat (limited to 'src')
-rw-r--r--src/Emby.Server/ApplicationPathHelper.cs40
-rw-r--r--src/Emby.Server/CoreAppHost.cs107
-rw-r--r--src/Emby.Server/CoreSystemEvents.cs11
-rw-r--r--src/Emby.Server/Data/DbConnector.cs52
-rw-r--r--src/Emby.Server/IO/MemoryStreamFactory.cs33
-rw-r--r--src/Emby.Server/PowerManagement.cs15
-rw-r--r--src/Emby.Server/Program.cs365
-rw-r--r--src/Emby.Server/project.json6
8 files changed, 310 insertions, 319 deletions
diff --git a/src/Emby.Server/ApplicationPathHelper.cs b/src/Emby.Server/ApplicationPathHelper.cs
new file mode 100644
index 000000000..c611ff372
--- /dev/null
+++ b/src/Emby.Server/ApplicationPathHelper.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Emby.Server
+{
+ public class ApplicationPathHelper
+ {
+ public static string GetProgramDataPath(string appDirectory)
+ {
+ var useDebugPath = false;
+
+#if DEBUG
+ useDebugPath = true;
+#endif
+
+ var programDataPath = useDebugPath ?
+ "programdata" :
+ "programdata";
+
+ programDataPath = programDataPath
+ .Replace('/', Path.DirectorySeparatorChar)
+ .Replace('\\', Path.DirectorySeparatorChar);
+
+ // If it's a relative path, e.g. "..\"
+ if (!Path.IsPathRooted(programDataPath))
+ {
+ programDataPath = Path.Combine(appDirectory, programDataPath);
+
+ programDataPath = Path.GetFullPath(programDataPath);
+ }
+
+ Directory.CreateDirectory(programDataPath);
+
+ return programDataPath;
+ }
+ }
+}
diff --git a/src/Emby.Server/CoreAppHost.cs b/src/Emby.Server/CoreAppHost.cs
new file mode 100644
index 000000000..21f6ae445
--- /dev/null
+++ b/src/Emby.Server/CoreAppHost.cs
@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using Emby.Server.Core;
+using Emby.Server.Core.Data;
+using Emby.Server.Core.FFMpeg;
+using Emby.Server.Data;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.System;
+
+namespace Emby.Server
+{
+ public class CoreAppHost : ApplicationHost
+ {
+ public CoreAppHost(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> certificateGenerator, Func<string> defaultUsernameFactory)
+ : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
+ {
+ }
+
+ public override bool IsRunningAsService
+ {
+ get { return false; }
+ }
+
+ protected override void RestartInternal()
+ {
+ Program.Restart();
+ }
+
+ protected override void ShutdownInternal()
+ {
+ Program.Shutdown();
+ }
+
+ protected override FFMpegInstallInfo GetFfmpegInstallInfo()
+ {
+ var info = new FFMpegInstallInfo();
+
+ return info;
+ }
+
+ protected override List<Assembly> GetAssembliesWithPartsInternal()
+ {
+ var list = new List<Assembly>();
+
+ list.Add(GetType().GetTypeInfo().Assembly);
+
+ return list;
+ }
+
+ protected override void AuthorizeServer()
+ {
+ }
+
+ protected override IDbConnector GetDbConnector()
+ {
+ return new DbConnector(Logger);
+ }
+
+ protected override void ConfigureAutoRunInternal(bool autorun)
+ {
+ }
+
+ public override void LaunchUrl(string url)
+ {
+ }
+
+ protected override void EnableLoopbackInternal(string appName)
+ {
+ }
+
+ public override bool SupportsRunningAsService
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public override bool CanSelfRestart
+ {
+ get
+ {
+ return Program.CanSelfRestart;
+ }
+ }
+
+ public override bool SupportsAutoRunAtStartup
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public override bool CanSelfUpdate
+ {
+ get
+ {
+ return Program.CanSelfUpdate;
+ }
+ }
+ }
+}
diff --git a/src/Emby.Server/CoreSystemEvents.cs b/src/Emby.Server/CoreSystemEvents.cs
new file mode 100644
index 000000000..d83071fa8
--- /dev/null
+++ b/src/Emby.Server/CoreSystemEvents.cs
@@ -0,0 +1,11 @@
+using System;
+using MediaBrowser.Model.System;
+
+namespace Emby.Server
+{
+ public class CoreSystemEvents : ISystemEvents
+ {
+ public event EventHandler Resume;
+ public event EventHandler Suspend;
+ }
+}
diff --git a/src/Emby.Server/Data/DbConnector.cs b/src/Emby.Server/Data/DbConnector.cs
new file mode 100644
index 000000000..bd70cff6c
--- /dev/null
+++ b/src/Emby.Server/Data/DbConnector.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Data;
+using System.Threading.Tasks;
+using MediaBrowser.Model.Logging;
+using Emby.Server.Core.Data;
+using Microsoft.Data.Sqlite;
+
+namespace Emby.Server.Data
+{
+ public class DbConnector : IDbConnector
+ {
+ private readonly ILogger _logger;
+
+ public DbConnector(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+ public async Task<IDbConnection> Connect(string dbPath, bool isReadOnly, bool enablePooling = false, int? cacheSize = null)
+ {
+ if (string.IsNullOrEmpty(dbPath))
+ {
+ throw new ArgumentNullException("dbPath");
+ }
+
+ //SQLiteConnection.SetMemoryStatus(false);
+
+ var connectionstr = new SqliteConnectionStringBuilder
+ {
+ //PageSize = 4096,
+ //CacheSize = cacheSize ?? 2000,
+ //SyncMode = SynchronizationModes.Normal,
+ DataSource = dbPath,
+ //JournalMode = SQLiteJournalModeEnum.Wal,
+
+ // This is causing crashing under linux
+ //Pooling = enablePooling && Environment.OSVersion.Platform == PlatformID.Win32NT,
+ //ReadOnly = isReadOnly,
+ Cache = enablePooling ? SqliteCacheMode.Default : SqliteCacheMode.Private,
+ Mode = isReadOnly ? SqliteOpenMode.ReadOnly : SqliteOpenMode.ReadWriteCreate
+ };
+
+ var connectionString = connectionstr.ConnectionString;
+
+ var connection = new SqliteConnection(connectionString);
+
+ await connection.OpenAsync().ConfigureAwait(false);
+
+ return connection;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Emby.Server/IO/MemoryStreamFactory.cs b/src/Emby.Server/IO/MemoryStreamFactory.cs
new file mode 100644
index 000000000..37ac2959e
--- /dev/null
+++ b/src/Emby.Server/IO/MemoryStreamFactory.cs
@@ -0,0 +1,33 @@
+using System;
+using System.IO;
+using MediaBrowser.Model.IO;
+
+namespace Emby.Server.IO
+{
+ public class MemoryStreamFactory : IMemoryStreamFactory
+ {
+ public MemoryStream CreateNew()
+ {
+ return new MemoryStream();
+ }
+
+ public MemoryStream CreateNew(int capacity)
+ {
+ return new MemoryStream(capacity);
+ }
+
+ public MemoryStream CreateNew(byte[] buffer)
+ {
+ return new MemoryStream(buffer);
+ }
+
+ public bool TryGetBuffer(MemoryStream stream, out byte[] buffer)
+ {
+ ArraySegment<byte> arrayBuffer;
+ stream.TryGetBuffer(out arrayBuffer);
+
+ buffer = arrayBuffer.Array;
+ return true;
+ }
+ }
+}
diff --git a/src/Emby.Server/PowerManagement.cs b/src/Emby.Server/PowerManagement.cs
new file mode 100644
index 000000000..85e3b72a6
--- /dev/null
+++ b/src/Emby.Server/PowerManagement.cs
@@ -0,0 +1,15 @@
+using MediaBrowser.Model.System;
+
+namespace Emby.Server
+{
+ public class PowerManagement : IPowerManagement
+ {
+ public void PreventSystemStandby()
+ {
+ }
+
+ public void AllowSystemStandby()
+ {
+ }
+ }
+}
diff --git a/src/Emby.Server/Program.cs b/src/Emby.Server/Program.cs
index d364e7284..6f871990d 100644
--- a/src/Emby.Server/Program.cs
+++ b/src/Emby.Server/Program.cs
@@ -1,33 +1,24 @@
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Implementations;
-using MediaBrowser.Server.Startup.Common;
-using MediaBrowser.ServerApplication.Native;
-using MediaBrowser.ServerApplication.Splash;
-using MediaBrowser.ServerApplication.Updates;
using Microsoft.Win32;
using System;
-using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.Linq;
-using System.Management;
using System.Runtime.InteropServices;
-using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using System.Windows.Forms;
using Emby.Common.Implementations.EnvironmentInfo;
using Emby.Common.Implementations.IO;
using Emby.Common.Implementations.Logging;
using Emby.Common.Implementations.Networking;
-using Emby.Common.Implementations.Security;
+using Emby.Drawing;
using Emby.Server.Core;
using Emby.Server.Core.Browser;
using Emby.Server.Implementations.IO;
-using ImageMagickSharp;
using MediaBrowser.Common.Net;
-using MediaBrowser.Server.Startup.Common.IO;
+using Emby.Server.IO;
namespace Emby.Server
{
@@ -37,8 +28,6 @@ namespace Emby.Server
private static ILogger _logger;
- private static bool _isRunningAsService = false;
- private static bool _canRestartService = false;
private static bool _appHostDisposed;
[DllImport("kernel32.dll", SetLastError = true)]
@@ -50,39 +39,33 @@ namespace Emby.Server
public static void Main(string[] args)
{
var options = new StartupOptions();
- _isRunningAsService = options.ContainsOption("-service");
-
- if (_isRunningAsService)
- {
- //_canRestartService = CanRestartWindowsService();
- }
var currentProcess = Process.GetCurrentProcess();
+
+ var baseDirectory = System.AppContext.BaseDirectory;
+ //var architecturePath = Path.Combine(Path.GetDirectoryName(applicationPath), Environment.Is64BitProcess ? "x64" : "x86");
- var applicationPath = currentProcess.MainModule.FileName;
- var architecturePath = Path.Combine(Path.GetDirectoryName(applicationPath), Environment.Is64BitProcess ? "x64" : "x86");
+ //Wand.SetMagickCoderModulePath(architecturePath);
- Wand.SetMagickCoderModulePath(architecturePath);
+ //var success = SetDllDirectory(architecturePath);
- var success = SetDllDirectory(architecturePath);
-
- var appPaths = CreateApplicationPaths(applicationPath, _isRunningAsService);
+ var appPaths = CreateApplicationPaths(baseDirectory);
var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
logManager.ReloadLogger(LogSeverity.Debug);
logManager.AddConsoleOutput();
var logger = _logger = logManager.GetLogger("Main");
-
+
ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
- if (IsAlreadyRunning(applicationPath, currentProcess))
- {
- logger.Info("Shutting down because another instance of Emby Server is already running.");
- return;
- }
+ //if (IsAlreadyRunning(applicationPath, currentProcess))
+ //{
+ // logger.Info("Shutting down because another instance of Emby Server is already running.");
+ // return;
+ //}
if (PerformUpdateIfNeeded(appPaths, logger))
{
@@ -90,14 +73,7 @@ namespace Emby.Server
return;
}
- try
- {
- RunApplication(appPaths, logManager, _isRunningAsService, options);
- }
- finally
- {
- OnServiceShutdown();
- }
+ RunApplication(appPaths, logManager, options);
}
/// <summary>
@@ -148,34 +124,17 @@ namespace Emby.Server
}
}
- if (!_isRunningAsService)
- {
- return false;
- }
-
return false;
}
/// <summary>
/// Creates the application paths.
/// </summary>
- /// <param name="applicationPath">The application path.</param>
- /// <param name="runAsService">if set to <c>true</c> [run as service].</param>
- /// <returns>ServerApplicationPaths.</returns>
- private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, bool runAsService)
+ private static ServerApplicationPaths CreateApplicationPaths(string appDirectory)
{
- var resourcesPath = Path.GetDirectoryName(applicationPath);
-
- if (runAsService)
- {
- var systemPath = Path.GetDirectoryName(applicationPath);
-
- var programDataPath = Path.GetDirectoryName(systemPath);
-
- return new ServerApplicationPaths(programDataPath, applicationPath, resourcesPath);
- }
+ var resourcesPath = appDirectory;
- return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath, resourcesPath);
+ return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(appDirectory), appDirectory, resourcesPath);
}
/// <summary>
@@ -186,14 +145,7 @@ namespace Emby.Server
{
get
{
- if (_isRunningAsService)
- {
- return _canRestartService;
- }
- else
- {
- return true;
- }
+ return true;
}
}
@@ -205,14 +157,7 @@ namespace Emby.Server
{
get
{
- if (_isRunningAsService)
- {
- return _canRestartService;
- }
- else
- {
- return true;
- }
+ return false;
}
}
@@ -223,123 +168,49 @@ namespace Emby.Server
/// </summary>
/// <param name="appPaths">The app paths.</param>
/// <param name="logManager">The log manager.</param>
- /// <param name="runService">if set to <c>true</c> [run service].</param>
/// <param name="options">The options.</param>
- private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options)
+ private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)
{
- var fileSystem = new WindowsFileSystem(logManager.GetLogger("FileSystem"));
- fileSystem.AddShortcutHandler(new LnkShortcutHandler());
- fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
+ var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, true);
- var nativeApp = new WindowsApp(fileSystem, _logger)
- {
- IsRunningAsService = runService
- };
+ fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
- var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths);
+ var imageEncoder = new NullImageEncoder();
- _appHost = new ApplicationHost(appPaths,
+ _appHost = new CoreAppHost(appPaths,
logManager,
options,
fileSystem,
- nativeApp,
new PowerManagement(),
"emby.windows.zip",
new EnvironmentInfo(),
imageEncoder,
- new Server.Startup.Common.SystemEvents(logManager.GetLogger("SystemEvents")),
- new RecyclableMemoryStreamProvider(),
+ new CoreSystemEvents(),
+ new MemoryStreamFactory(),
new NetworkManager(logManager.GetLogger("NetworkManager")),
GenerateCertificate,
- () => Environment.UserDomainName);
+ () => "EmbyUser");
var initProgress = new Progress<double>();
- if (!runService)
- {
- // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
- SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
- ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
- }
+ // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
+ SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
+ ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
var task = _appHost.Init(initProgress);
Task.WaitAll(task);
task = task.ContinueWith(new Action<Task>(a => _appHost.RunStartupTasks()), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent);
- if (runService)
- {
- StartService(logManager);
- }
- else
- {
- Task.WaitAll(task);
-
- task = InstallVcredist2013IfNeeded(_appHost, _logger);
- Task.WaitAll(task);
-
- Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding;
- Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
+ Task.WaitAll(task);
- task = ApplicationTaskCompletionSource.Task;
- Task.WaitAll(task);
- }
+ task = ApplicationTaskCompletionSource.Task;
+ Task.WaitAll(task);
}
private static void GenerateCertificate(string certPath, string certHost)
{
- CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, _logger);
- }
-
- static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
- {
- if (e.Reason == SessionSwitchReason.SessionLogon)
- {
- BrowserLauncher.OpenDashboard(_appHost);
- }
- }
-
- /// <summary>
- /// Starts the service.
- /// </summary>
- private static void StartService(ILogManager logManager)
- {
- var service = new BackgroundService(logManager.GetLogger("Service"));
-
- service.Disposed += service_Disposed;
-
- ServiceBase.Run(service);
- }
-
- /// <summary>
- /// Handles the Disposed event of the service control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- static void service_Disposed(object sender, EventArgs e)
- {
- ApplicationTaskCompletionSource.SetResult(true);
- OnServiceShutdown();
- }
-
- private static void OnServiceShutdown()
- {
- _logger.Info("Shutting down");
-
- DisposeAppHost();
- }
-
- /// <summary>
- /// Handles the SessionEnding event of the SystemEvents control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="SessionEndingEventArgs"/> instance containing the event data.</param>
- static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
- {
- if (e.Reason == SessionEndReasons.SystemShutdown || !_isRunningAsService)
- {
- Shutdown();
- }
+ //CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, _logger);
}
/// <summary>
@@ -353,10 +224,7 @@ namespace Emby.Server
new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
- if (!_isRunningAsService)
- {
- MessageBox.Show("Unhandled exception: " + exception.Message);
- }
+ ShowMessageBox("Unhandled exception: " + exception.Message);
if (!Debugger.IsAttached)
{
@@ -372,80 +240,18 @@ namespace Emby.Server
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
private static bool PerformUpdateIfNeeded(ServerApplicationPaths appPaths, ILogger logger)
{
- // Look for the existence of an update archive
- var updateArchive = Path.Combine(appPaths.TempUpdatePath, "MBServer" + ".zip");
- if (File.Exists(updateArchive))
- {
- logger.Info("An update is available from {0}", updateArchive);
-
- // Update is there - execute update
- try
- {
- var serviceName = _isRunningAsService ? BackgroundService.GetExistingServiceName() : string.Empty;
- new ApplicationUpdater().UpdateApplication(appPaths, updateArchive, logger, serviceName);
-
- // And just let the app exit so it can update
- return true;
- }
- catch (Exception e)
- {
- logger.ErrorException("Error starting updater.", e);
-
- MessageBox.Show(string.Format("Error attempting to update application.\n\n{0}\n\n{1}", e.GetType().Name, e.Message));
- }
- }
-
return false;
}
- public static void Shutdown()
+ private static void ShowMessageBox(string msg)
{
- if (_isRunningAsService)
- {
- ShutdownWindowsService();
- }
- else
- {
- DisposeAppHost();
- ShutdownWindowsApplication();
- }
}
- public static void Restart()
+ public static void Shutdown()
{
DisposeAppHost();
- if (_isRunningAsService)
- {
- RestartWindowsService();
- }
- else
- {
- //_logger.Info("Hiding server notify icon");
- //_serverNotifyIcon.Visible = false;
-
- _logger.Info("Starting new instance");
- //Application.Restart();
- Process.Start(_appHost.ServerConfigurationManager.ApplicationPaths.ApplicationPath);
-
- ShutdownWindowsApplication();
- }
- }
-
- private static void DisposeAppHost()
- {
- if (!_appHostDisposed)
- {
- _logger.Info("Disposing app host");
-
- _appHostDisposed = true;
- _appHost.Dispose();
- }
- }
-
- private static void ShutdownWindowsApplication()
- {
//_logger.Info("Calling Application.Exit");
//Application.Exit();
@@ -456,101 +262,24 @@ namespace Emby.Server
ApplicationTaskCompletionSource.SetResult(true);
}
- private static void ShutdownWindowsService()
- {
- }
-
- private static void RestartWindowsService()
- {
- }
-
- private static bool CanRestartWindowsService()
- {
- return false;
- }
-
- private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger)
+ public static void Restart()
{
- // Reference
- // http://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed
+ DisposeAppHost();
- try
- {
- var subkey = Environment.Is64BitProcess
- ? "SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x64"
- : "SOFTWARE\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x86";
+ // todo: start new instance
- using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default)
- .OpenSubKey(subkey))
- {
- if (ndpKey != null && ndpKey.GetValue("Version") != null)
- {
- var installedVersion = ((string)ndpKey.GetValue("Version")).TrimStart('v');
- if (installedVersion.StartsWith("12", StringComparison.OrdinalIgnoreCase))
- {
- return;
- }
- }
- }
- }
- catch (Exception ex)
- {
- logger.ErrorException("Error getting .NET Framework version", ex);
- return;
- }
-
- try
- {
- await InstallVcredist2013().ConfigureAwait(false);
- }
- catch (Exception ex)
- {
- logger.ErrorException("Error installing Visual Studio C++ runtime", ex);
- }
+ Shutdown();
}
- private async static Task InstallVcredist2013()
+ private static void DisposeAppHost()
{
- var httpClient = _appHost.HttpClient;
-
- var tmp = await httpClient.GetTempFile(new HttpRequestOptions
- {
- Url = GetVcredist2013Url(),
- Progress = new Progress<double>()
-
- }).ConfigureAwait(false);
-
- var exePath = Path.ChangeExtension(tmp, ".exe");
- File.Copy(tmp, exePath);
-
- var startInfo = new ProcessStartInfo
- {
- FileName = exePath,
-
- CreateNoWindow = true,
- WindowStyle = ProcessWindowStyle.Hidden,
- Verb = "runas",
- ErrorDialog = false
- };
-
- _logger.Info("Running {0}", startInfo.FileName);
-
- using (var process = Process.Start(startInfo))
+ if (!_appHostDisposed)
{
- process.WaitForExit();
- }
- }
+ _logger.Info("Disposing app host");
- private static string GetVcredist2013Url()
- {
- if (Environment.Is64BitProcess)
- {
- return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x64.exe";
+ _appHostDisposed = true;
+ _appHost.Dispose();
}
-
- // TODO: ARM url - https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_arm.exe
-
- return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x86.exe";
}
/// <summary>
diff --git a/src/Emby.Server/project.json b/src/Emby.Server/project.json
index 2693435a4..55acee514 100644
--- a/src/Emby.Server/project.json
+++ b/src/Emby.Server/project.json
@@ -11,7 +11,11 @@
"type": "platform",
"version": "1.0.1"
},
- "Mono.Nat": "1.0.0-*"
+ "Mono.Nat": "1.0.0-*",
+ "Microsoft.Win32.Registry": "4.0.0",
+ "System.Runtime.Extensions": "4.1.0",
+ "System.Diagnostics.Process": "4.1.0",
+ "Microsoft.Data.SQLite": "1.1.0-preview1-final"
},
"frameworks": {