#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.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)
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue