From 804115bf8d526477756828ff4ca632c351e03b90 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 8 Apr 2013 11:55:53 -0400 Subject: remove and/or delay unnecessary startup work --- MediaBrowser.Common.Implementations/BaseApplicationHost.cs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'MediaBrowser.Common.Implementations/BaseApplicationHost.cs') diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 017f69b62..4b8574c89 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -195,8 +195,6 @@ namespace MediaBrowser.Common.Implementations Task.Run(() => ConfigureAutoRunAtStartup()); - Task.Run(() => SecurityManager.LoadAllRegistrationInfo()); - ConfigurationManager.ConfigurationUpdated += ConfigurationManager_ConfigurationUpdated; }); } @@ -236,11 +234,6 @@ namespace MediaBrowser.Common.Implementations var assemblies = GetComposablePartAssemblies().ToArray(); - foreach (var assembly in assemblies) - { - Logger.Info("Loading {0}", assembly.FullName); - } - AllTypes = assemblies.SelectMany(GetTypes).ToArray(); AllConcreteTypes = AllTypes.Where(t => t.IsClass && !t.IsAbstract && !t.IsInterface && !t.IsGenericType).ToArray(); @@ -270,19 +263,15 @@ namespace MediaBrowser.Common.Implementations RegisterSingleInstance(TaskManager); HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger); - RegisterSingleInstance(HttpClient); NetworkManager = new NetworkManager(); - RegisterSingleInstance(NetworkManager); SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths); - RegisterSingleInstance(SecurityManager); PackageManager = new PackageManager(SecurityManager, NetworkManager, HttpClient, ApplicationPaths, JsonSerializer, Logger); - RegisterSingleInstance(PackageManager); }); } -- cgit v1.2.3 From 57f082051d15da7450fe41f293e0131c8320db33 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 8 Apr 2013 12:45:40 -0400 Subject: tweaked http server startup --- .../BaseApplicationHost.cs | 6 ++++++ MediaBrowser.ServerApplication/ApplicationHost.cs | 23 +++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.Common.Implementations/BaseApplicationHost.cs') diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 4b8574c89..1a2ab4a51 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -171,6 +171,7 @@ namespace MediaBrowser.Common.Implementations Logger = LogManager.GetLogger("App"); LogManager.ReloadLogger(ConfigurationManager.CommonConfiguration.EnableDebugLevelLogging ? LogSeverity.Debug : LogSeverity.Info); + OnLoggerLoaded(); DiscoverTypes(); @@ -183,6 +184,11 @@ namespace MediaBrowser.Common.Implementations await RunStartupTasks().ConfigureAwait(false); } + protected virtual void OnLoggerLoaded() + { + + } + /// /// Runs the startup tasks. /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index b5e267810..582b73a31 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -160,6 +160,8 @@ namespace MediaBrowser.ServerApplication get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk"); } } + private Task _httpServerCreationTask; + /// /// Runs the startup tasks. /// @@ -175,6 +177,16 @@ namespace MediaBrowser.ServerApplication Parallel.ForEach(GetExports(), entryPoint => entryPoint.Run()); } + /// + /// Called when [logger loaded]. + /// + protected override void OnLoggerLoaded() + { + base.OnLoggerLoaded(); + + _httpServerCreationTask = Task.Run(() => ServerFactory.CreateServer(this, Logger, "Media Browser", "index.html")); + } + /// /// Registers resources that classes will depend on /// @@ -183,12 +195,6 @@ namespace MediaBrowser.ServerApplication { ServerKernel = new Kernel(ServerConfigurationManager); - var httpServerTask = Task.Run(() => - { - HttpServer = ServerFactory.CreateServer(this, Logger, "Media Browser", "index.html"); - RegisterSingleInstance(HttpServer, false); - }); - await base.RegisterResources().ConfigureAwait(false); RegisterSingleInstance(new HttpResultFactory(LogManager)); @@ -230,6 +236,9 @@ namespace MediaBrowser.ServerApplication MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), ZipClient, ApplicationPaths, JsonSerializer); RegisterSingleInstance(MediaEncoder); + HttpServer = await _httpServerCreationTask.ConfigureAwait(false); + RegisterSingleInstance(HttpServer, false); + ServerManager = new ServerManager(this, JsonSerializer, Logger, ServerConfigurationManager, ServerKernel); RegisterSingleInstance(ServerManager); @@ -238,7 +247,7 @@ namespace MediaBrowser.ServerApplication var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false)); var userTask = Task.Run(async () => await ConfigureUserRepositories().ConfigureAwait(false)); - await Task.WhenAll(httpServerTask, itemsTask, userTask, displayPreferencesTask, userdataTask).ConfigureAwait(false); + await Task.WhenAll(itemsTask, userTask, displayPreferencesTask, userdataTask).ConfigureAwait(false); SetKernelProperties(); } -- cgit v1.2.3