#74 - Log the listening addresses at startup.
This commit is contained in:
parent
f6aa12cfa8
commit
3fdf656353
|
|
@ -22,17 +22,21 @@ using System.Threading;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Server.WebListener;
|
using Microsoft.AspNet.Server.WebListener;
|
||||||
|
using Microsoft.Framework.Logging;
|
||||||
|
using Microsoft.Framework.Logging.Console;
|
||||||
using Microsoft.Net.Http.Server;
|
using Microsoft.Net.Http.Server;
|
||||||
|
|
||||||
namespace SelfHostServer
|
namespace SelfHostServer
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
|
||||||
{
|
{
|
||||||
var info = (ServerInformation)app.Server;
|
var info = (ServerInformation)app.Server;
|
||||||
info.Listener.AuthenticationManager.AuthenticationTypes = AuthenticationTypes.AllowAnonymous;
|
info.Listener.AuthenticationManager.AuthenticationTypes = AuthenticationTypes.AllowAnonymous;
|
||||||
|
|
||||||
|
loggerfactory.AddConsole();
|
||||||
|
|
||||||
app.Run(async context =>
|
app.Run(async context =>
|
||||||
{
|
{
|
||||||
if (context.IsWebSocketRequest)
|
if (context.IsWebSocketRequest)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.Http": "1.0.0-*",
|
"Microsoft.AspNet.Hosting": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Server.WebListener": "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" },
|
"commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:8080" },
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,6 @@ namespace Microsoft.AspNet.Server.WebListener
|
||||||
throw new InvalidOperationException("No address prefixes were defined.");
|
throw new InvalidOperationException("No address prefixes were defined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
LogHelper.LogInfo(_logger, "Start");
|
|
||||||
|
|
||||||
_listener.Start();
|
_listener.Start();
|
||||||
|
|
||||||
ActivateRequestProcessingLimits();
|
ActivateRequestProcessingLimits();
|
||||||
|
|
@ -204,11 +202,11 @@ namespace Microsoft.AspNet.Server.WebListener
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
LogHelper.LogInfo(_logger, "Stop");
|
|
||||||
_stopping = true;
|
_stopping = true;
|
||||||
// Wait for active requests to drain
|
// Wait for active requests to drain
|
||||||
if (_outstandingRequests > 0)
|
if (_outstandingRequests > 0)
|
||||||
{
|
{
|
||||||
|
LogHelper.LogInfo(_logger, "Stopping, waiting for " + _outstandingRequests + " request(s) to drain.");
|
||||||
_shutdownSignal.WaitOne();
|
_shutdownSignal.WaitOne();
|
||||||
}
|
}
|
||||||
// All requests are finished
|
// All requests are finished
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNet.Server.WebListener
|
||||||
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Disposed by caller")]
|
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Disposed by caller")]
|
||||||
public IServerInformation Initialize(IConfiguration configuration)
|
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);
|
ParseAddresses(configuration, listener);
|
||||||
return new ServerInformation(new MessagePump(listener, _loggerFactory));
|
return new ServerInformation(new MessagePump(listener, _loggerFactory));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,9 +162,9 @@ namespace Microsoft.Net.Http.Server
|
||||||
|
|
||||||
private void RegisterPrefix(string uriPrefix, int contextId)
|
private void RegisterPrefix(string uriPrefix, int contextId)
|
||||||
{
|
{
|
||||||
uint statusCode = 0;
|
LogHelper.LogInfo(_webListener.Logger, "Listening on prefix: " + uriPrefix);
|
||||||
|
|
||||||
statusCode =
|
uint statusCode =
|
||||||
UnsafeNclNativeMethods.HttpApi.HttpAddUrlToUrlGroup(
|
UnsafeNclNativeMethods.HttpApi.HttpAddUrlToUrlGroup(
|
||||||
_webListener.UrlGroupId,
|
_webListener.UrlGroupId,
|
||||||
uriPrefix,
|
uriPrefix,
|
||||||
|
|
@ -187,6 +187,7 @@ namespace Microsoft.Net.Http.Server
|
||||||
private bool UnregisterPrefix(string uriPrefix)
|
private bool UnregisterPrefix(string uriPrefix)
|
||||||
{
|
{
|
||||||
uint statusCode = 0;
|
uint statusCode = 0;
|
||||||
|
LogHelper.LogInfo(_webListener.Logger, "Stop listening on prefix: " + uriPrefix);
|
||||||
|
|
||||||
statusCode =
|
statusCode =
|
||||||
UnsafeNclNativeMethods.HttpApi.HttpRemoveUrlFromUrlGroup(
|
UnsafeNclNativeMethods.HttpApi.HttpRemoveUrlFromUrlGroup(
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,12 @@ namespace Microsoft.Net.Http.Server
|
||||||
_connectionCancellationTokens = new ConcurrentDictionary<ulong, ConnectionCancellation>();
|
_connectionCancellationTokens = new ConcurrentDictionary<ulong, ConnectionCancellation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WebListener(ILoggerFactory factory)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
_logger = LogHelper.CreateLogger(factory, typeof(WebListener));
|
||||||
|
}
|
||||||
|
|
||||||
internal enum State
|
internal enum State
|
||||||
{
|
{
|
||||||
Stopped,
|
Stopped,
|
||||||
|
|
@ -470,7 +476,6 @@ namespace Microsoft.Net.Http.Server
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogHelper.LogInfo(_logger, "Stop");
|
|
||||||
|
|
||||||
_urlPrefixes.UnregisterAllPrefixes();
|
_urlPrefixes.UnregisterAllPrefixes();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue