#74 - Log the listening addresses at startup.

This commit is contained in:
Chris Ross 2014-11-17 10:00:24 -08:00
parent f6aa12cfa8
commit 3fdf656353
6 changed files with 19 additions and 10 deletions

View File

@ -22,17 +22,21 @@ using System.Threading;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Server.WebListener;
using Microsoft.Framework.Logging;
using Microsoft.Framework.Logging.Console;
using Microsoft.Net.Http.Server;
namespace SelfHostServer
{
public class Startup
{
public void Configure(IApplicationBuilder app)
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
{
var info = (ServerInformation)app.Server;
info.Listener.AuthenticationManager.AuthenticationTypes = AuthenticationTypes.AllowAnonymous;
loggerfactory.AddConsole();
app.Run(async context =>
{
if (context.IsWebSocketRequest)

View File

@ -1,7 +1,8 @@
{
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*"
"Microsoft.AspNet.Hosting": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.Framework.Logging.Console": "1.0.0-*"
},
"commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:8080" },
"frameworks": {

View File

@ -91,8 +91,6 @@ namespace Microsoft.AspNet.Server.WebListener
throw new InvalidOperationException("No address prefixes were defined.");
}
LogHelper.LogInfo(_logger, "Start");
_listener.Start();
ActivateRequestProcessingLimits();
@ -204,11 +202,11 @@ namespace Microsoft.AspNet.Server.WebListener
public void Dispose()
{
LogHelper.LogInfo(_logger, "Stop");
_stopping = true;
// Wait for active requests to drain
if (_outstandingRequests > 0)
{
LogHelper.LogInfo(_logger, "Stopping, waiting for " + _outstandingRequests + " request(s) to drain.");
_shutdownSignal.WaitOne();
}
// All requests are finished

View File

@ -68,7 +68,7 @@ namespace Microsoft.AspNet.Server.WebListener
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Disposed by caller")]
public IServerInformation Initialize(IConfiguration configuration)
{
Microsoft.Net.Http.Server.WebListener listener = new Microsoft.Net.Http.Server.WebListener();
Microsoft.Net.Http.Server.WebListener listener = new Microsoft.Net.Http.Server.WebListener(_loggerFactory);
ParseAddresses(configuration, listener);
return new ServerInformation(new MessagePump(listener, _loggerFactory));
}

View File

@ -162,9 +162,9 @@ namespace Microsoft.Net.Http.Server
private void RegisterPrefix(string uriPrefix, int contextId)
{
uint statusCode = 0;
LogHelper.LogInfo(_webListener.Logger, "Listening on prefix: " + uriPrefix);
statusCode =
uint statusCode =
UnsafeNclNativeMethods.HttpApi.HttpAddUrlToUrlGroup(
_webListener.UrlGroupId,
uriPrefix,
@ -187,6 +187,7 @@ namespace Microsoft.Net.Http.Server
private bool UnregisterPrefix(string uriPrefix)
{
uint statusCode = 0;
LogHelper.LogInfo(_webListener.Logger, "Stop listening on prefix: " + uriPrefix);
statusCode =
UnsafeNclNativeMethods.HttpApi.HttpRemoveUrlFromUrlGroup(

View File

@ -109,6 +109,12 @@ namespace Microsoft.Net.Http.Server
_connectionCancellationTokens = new ConcurrentDictionary<ulong, ConnectionCancellation>();
}
public WebListener(ILoggerFactory factory)
: this()
{
_logger = LogHelper.CreateLogger(factory, typeof(WebListener));
}
internal enum State
{
Stopped,
@ -470,7 +476,6 @@ namespace Microsoft.Net.Http.Server
{
return;
}
LogHelper.LogInfo(_logger, "Stop");
_urlPrefixes.UnregisterAllPrefixes();