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 --- .../HttpServer/HttpServer.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs index 6aea83410..c2a936f1c 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs @@ -49,12 +49,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// private readonly List _restServices = new List(); - /// - /// Gets or sets the application host. - /// - /// The application host. - private IApplicationHost ApplicationHost { get; set; } - /// /// This subscribes to HttpListener requests and finds the appropriate BaseHandler to process it /// @@ -78,6 +72,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The name of the server. private string ServerName { get; set; } + private ContainerAdapter _containerAdapter; + /// /// Initializes a new instance of the class. /// @@ -109,10 +105,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer ServerName = serverName; DefaultRedirectPath = defaultRedirectpath; _logger = logger; - ApplicationHost = applicationHost; EndpointHostConfig.Instance.ServiceStackHandlerFactoryPath = null; EndpointHostConfig.Instance.MetadataRedirectPath = "metadata"; + + _containerAdapter = new ContainerAdapter(applicationHost); } protected static readonly CultureInfo UsCulture = new CultureInfo("en-US"); @@ -135,7 +132,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer WriteErrorsToResponse = false }); - container.Adapter = new ContainerAdapter(ApplicationHost); + container.Adapter = _containerAdapter; Plugins.Add(new SwaggerFeature()); Plugins.Add(new CorsFeature()); @@ -214,6 +211,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer if (Listener == null) { + _logger.Info("Creating HttpListner"); Listener = new HttpListener(); } @@ -221,11 +219,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer UrlPrefix = urlBase; + _logger.Info("Adding HttpListener Prefixes"); Listener.Prefixes.Add(urlBase); IsStarted = true; + _logger.Info("Starting HttpListner"); Listener.Start(); + _logger.Info("Creating HttpListner observable stream"); HttpListener = CreateObservableStream().Subscribe(ProcessHttpRequestAsync); } @@ -548,6 +549,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer _restServices.AddRange(services); _logger.Info("Calling EndpointHost.ConfigureHost"); + EndpointHost.ConfigureHost(this, ServerName, CreateServiceManager()); _logger.Info("Calling ServiceStack AppHost.Init"); -- cgit v1.2.3