update .net core startup

This commit is contained in:
Luke Pulverenti 2016-11-20 18:48:52 -05:00
parent 94e622e3a0
commit e297e90bce
9 changed files with 127 additions and 62 deletions

View file

@ -132,6 +132,8 @@ using SocketHttpListener.Primitives;
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
using Emby.Drawing;
using Emby.Server.Implementations.Migrations;
using MediaBrowser.Model.Diagnostics;
using Emby.Common.Implementations.Diagnostics;
namespace Emby.Server.Core
{
@ -1543,7 +1545,39 @@ namespace Emby.Server.Core
}
}
public abstract void LaunchUrl(string url);
public void LaunchUrl(string url)
{
if (EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows)
{
throw new NotImplementedException();
}
var process = ProcessFactory.Create(new ProcessOptions {
FileName = url,
EnableRaisingEvents = true,
UseShellExecute = true,
ErrorDialog = false
});
process.Exited += ProcessExited;
try
{
process.Start();
}
catch (Exception ex)
{
Console.WriteLine("Error launching url: {0}", url);
Logger.ErrorException("Error launching url: {0}", ex, url);
throw;
}
}
private static void ProcessExited(object sender, EventArgs e)
{
((IProcess)sender).Dispose();
}
public void EnableLoopback(string appName)
{

View file

@ -12,12 +12,22 @@ namespace Emby.Server.Implementations.Data
public abstract class BaseSqliteRepository : IDisposable
{
protected string DbFilePath { get; set; }
protected ReaderWriterLockSlim WriteLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
protected ReaderWriterLockSlim WriteLock;
protected ILogger Logger { get; private set; }
protected BaseSqliteRepository(ILogger logger)
{
Logger = logger;
WriteLock = AllowLockRecursion ?
new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion) :
new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
}
protected virtual bool AllowLockRecursion
{
get { return false; }
}
protected virtual bool EnableConnectionPooling
@ -86,7 +96,7 @@ namespace Emby.Server.Implementations.Data
var cacheSize = CacheSize;
if (cacheSize.HasValue)
{
}
if (EnableExclusiveMode)
@ -206,11 +216,7 @@ namespace Emby.Server.Implementations.Data
return;
}
connection.ExecuteAll(string.Join(";", new string[]
{
"alter table " + table,
"add column " + columnName + " " + type + " NULL"
}));
connection.Execute("alter table " + table + " add column " + columnName + " " + type + " NULL");
}
}

View file

@ -95,6 +95,14 @@ namespace Emby.Server.Implementations.Data
DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
}
protected override bool AllowLockRecursion
{
get
{
return true;
}
}
private const string ChaptersTableName = "Chapters2";
protected override int? CacheSize

View file

@ -89,7 +89,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
Url = url,
CancellationToken = cancellationToken,
BufferContent = false
BufferContent = false,
// Increase a little bit
TimeoutMs = 30000
}, "GET").ConfigureAwait(false))
{

View file

@ -126,11 +126,6 @@ namespace MediaBrowser.Server.Mono
throw new NotImplementedException();
}
public override void LaunchUrl(string url)
{
throw new NotImplementedException();
}
protected override void EnableLoopbackInternal(string appName)
{
}

View file

@ -119,38 +119,6 @@ namespace MediaBrowser.ServerApplication
}
}
public override void LaunchUrl(string url)
{
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = url
},
EnableRaisingEvents = true,
};
process.Exited += ProcessExited;
try
{
process.Start();
}
catch (Exception ex)
{
Console.WriteLine("Error launching url: {0}", url);
Logger.ErrorException("Error launching url: {0}", ex, url);
throw;
}
}
private static void ProcessExited(object sender, EventArgs e)
{
((Process)sender).Dispose();
}
protected override void EnableLoopbackInternal(string appName)
{
LoopUtil.Run(appName);

View file

@ -4,8 +4,7 @@ using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Emby.Server.Core;
using Emby.Server.Core.FFMpeg;
using Emby.Server.Data;
using Emby.Server.Implementations.FFMpeg;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.System;
@ -39,9 +38,37 @@ namespace Emby.Server
{
var info = new FFMpegInstallInfo();
if (EnvironmentInfo.OperatingSystem == OperatingSystem.Windows)
{
info.FFMpegFilename = "ffmpeg.exe";
info.FFProbeFilename = "ffprobe.exe";
info.Version = "20160410";
info.ArchiveType = "7z";
info.DownloadUrls = GetDownloadUrls();
}
return info;
}
private string[] GetDownloadUrls()
{
switch (EnvironmentInfo.SystemArchitecture)
{
case Architecture.X64:
return new[]
{
"https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20160410-win64.7z"
};
case Architecture.X86:
return new[]
{
"https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20160410-win32.7z"
};
}
return new string[] { };
}
protected override List<Assembly> GetAssembliesWithPartsInternal()
{
var list = new List<Assembly>();
@ -59,10 +86,6 @@ namespace Emby.Server
{
}
public override void LaunchUrl(string url)
{
}
protected override void EnableLoopbackInternal(string appName)
{
}
@ -98,5 +121,13 @@ namespace Emby.Server
return Program.CanSelfUpdate;
}
}
protected override bool SupportsDualModeSockets
{
get
{
return true;
}
}
}
}

View file

@ -39,19 +39,34 @@ namespace Emby.Server
/// </summary>
public static void Main(string[] args)
{
var options = new StartupOptions();
var options = new StartupOptions(Environment.GetCommandLineArgs());
var environmentInfo = new EnvironmentInfo();
var currentProcess = Process.GetCurrentProcess();
var baseDirectory = System.AppContext.BaseDirectory;
//var architecturePath = Path.Combine(Path.GetDirectoryName(applicationPath), Environment.Is64BitProcess ? "x64" : "x86");
string archPath = baseDirectory;
if (environmentInfo.SystemArchitecture == MediaBrowser.Model.System.Architecture.X64)
{
archPath = Path.Combine(archPath, "x64");
}
else if (environmentInfo.SystemArchitecture == MediaBrowser.Model.System.Architecture.X86)
{
archPath = Path.Combine(archPath, "x86");
}
else
{
archPath = Path.Combine(archPath, "arm");
}
//Wand.SetMagickCoderModulePath(architecturePath);
//var success = SetDllDirectory(architecturePath);
if (environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows)
{
SetDllDirectory(archPath);
}
var appPaths = CreateApplicationPaths(baseDirectory);
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
SetSqliteProvider();
var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
logManager.ReloadLogger(LogSeverity.Debug);
@ -75,7 +90,12 @@ namespace Emby.Server
return;
}
RunApplication(appPaths, logManager, options);
RunApplication(appPaths, logManager, options, environmentInfo);
}
private static void SetSqliteProvider()
{
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
}
/// <summary>
@ -171,7 +191,7 @@ namespace Emby.Server
/// <param name="appPaths">The app paths.</param>
/// <param name="logManager">The log manager.</param>
/// <param name="options">The options.</param>
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options, EnvironmentInfo environmentInfo)
{
var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, true);
@ -185,7 +205,7 @@ namespace Emby.Server
fileSystem,
new PowerManagement(),
"emby.windows.zip",
new EnvironmentInfo(),
environmentInfo,
imageEncoder,
new CoreSystemEvents(),
new MemoryStreamFactory(),

View file

@ -15,7 +15,7 @@
"Microsoft.Win32.Registry": "4.0.0",
"System.Runtime.Extensions": "4.1.0",
"System.Diagnostics.Process": "4.1.0",
"SQLitePCLRaw.provider.sqlite3.netstandard11": "1.1.0"
"SQLitePCLRaw.provider.sqlite3.netstandard11": "1.1.1-pre20161109081005"
},
"frameworks": {