diff --git a/src/Kestrel/IKestrelServerInformation.cs b/src/Kestrel/IKestrelServerInformation.cs new file mode 100644 index 0000000000..a9fce59d09 --- /dev/null +++ b/src/Kestrel/IKestrelServerInformation.cs @@ -0,0 +1,10 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Kestrel +{ + public interface IKestrelServerInformation + { + int ThreadCount { get; set; } + } +} diff --git a/src/Kestrel/ServerFactory.cs b/src/Kestrel/ServerFactory.cs index ac60b4c4f2..784b1cdbdd 100644 --- a/src/Kestrel/ServerFactory.cs +++ b/src/Kestrel/ServerFactory.cs @@ -38,7 +38,7 @@ namespace Kestrel var disposables = new List(); var information = (ServerInformation)serverInformation; var engine = new KestrelEngine(_libraryManager, _appShutdownService); - engine.Start(Environment.ProcessorCount); + engine.Start(information.ThreadCount == 0 ? 1 : information.ThreadCount); foreach (var address in information.Addresses) { disposables.Add(engine.CreateServer( diff --git a/src/Kestrel/ServerInformation.cs b/src/Kestrel/ServerInformation.cs index dfbde7e91d..a3b770834c 100644 --- a/src/Kestrel/ServerInformation.cs +++ b/src/Kestrel/ServerInformation.cs @@ -8,7 +8,7 @@ using Microsoft.Framework.Configuration; namespace Kestrel { - public class ServerInformation : IServerInformation + public class ServerInformation : IServerInformation, IKestrelServerInformation { public ServerInformation() { @@ -25,7 +25,7 @@ namespace Kestrel foreach (var url in urls.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { var address = ServerAddress.FromUrl(url); - if(address != null) + if (address != null) { Addresses.Add(address); } @@ -41,5 +41,7 @@ namespace Kestrel } public IList Addresses { get; private set; } + + public int ThreadCount { get; set; } } }