/// <summary> /// Runs the application. /// </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) { var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, true, appPaths.TempDirectory); fileSystem.AddShortcutHandler(new LnkShortcutHandler()); fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths); _appHost = new WindowsAppHost(appPaths, logManager, options, fileSystem, new PowerManagement(), "emby.windows.zip", new EnvironmentInfo(), imageEncoder, new Server.Startup.Common.SystemEvents(logManager.GetLogger("SystemEvents")), new RecyclableMemoryStreamProvider(), new Networking.NetworkManager(logManager.GetLogger("NetworkManager")), GenerateCertificate, () => Environment.UserDomainName); var initProgress = new Progress<double>(); if (!runService) { if (!options.ContainsOption("-nosplash")) ShowSplashScreen(_appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash")); // 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.SessionSwitch += SystemEvents_SessionSwitch; HideSplashScreen(); ShowTrayIcon(); task = ApplicationTaskCompletionSource.Task; Task.WaitAll(task); } }
/// <summary> /// Runs the application. /// </summary> /// <param name="appPaths">The app paths.</param> /// <param name="logManager">The log manager.</param> /// <param name="options">The options.</param> private static void StartApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options) { SystemEvents.SessionEnding += SystemEvents_SessionEnding; // Allow all https requests ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); }); var fileSystem = new ManagedFileSystem(new PatternsLogger(logManager.GetLogger("FileSystem")), false, true); fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); var nativeApp = new NativeApp(); AppHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "MBServer.Mono", nativeApp); if (options.ContainsOption("-v")) { Console.WriteLine(AppHost.ApplicationVersion.ToString()); return; } Console.WriteLine("appHost.Init"); Task.Run(() => StartServer(CancellationToken.None)); }
/// <summary> /// Runs the application. /// </summary> /// <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, EnvironmentInfo environmentInfo) { var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), true, true, false, appPaths.TempDirectory); fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); var imageEncoder = new NullImageEncoder(); _appHost = new CoreAppHost(appPaths, logManager, options, fileSystem, new PowerManagement(), "emby.windows.zip", environmentInfo, imageEncoder, new CoreSystemEvents(), new MemoryStreamFactory(), new NetworkManager(logManager.GetLogger("NetworkManager")), GenerateCertificate, () => "EmbyUser"); var initProgress = new Progress <double>(); if (environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows) { // 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); Task.WaitAll(task); task = ApplicationTaskCompletionSource.Task; Task.WaitAll(task); }
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options) { SystemEvents.SessionEnding += SystemEvents_SessionEnding; // Allow all https requests ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); }); var fileSystem = new ManagedFileSystem(new PatternsLogger(logManager.GetLogger("FileSystem")), false, false); fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); var nativeApp = new NativeApp(options); _appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "emby.mono.zip", nativeApp); if (options.ContainsOption("-v")) { Console.WriteLine(_appHost.ApplicationVersion.ToString()); return; } Console.WriteLine("appHost.Init"); var initProgress = new Progress <double>(); var task = _appHost.Init(initProgress); Task.WaitAll(task); Console.WriteLine("Running startup tasks"); task = _appHost.RunStartupTasks(); Task.WaitAll(task); task = ApplicationTaskCompletionSource.Task; Task.WaitAll(task); }