private static IHost CreateHost <TStartup>(int port, bool localhost, IDictionary <string, string> configuration, IClusterMemberLifetime configurator = null) where TStartup : class { return(new HostBuilder() .ConfigureWebHost(webHost => webHost.UseKestrel(options => { if (localhost) { options.ListenLocalhost(port); } else { options.ListenAnyIP(port); } }) .ConfigureLogging(static builder => builder.AddDebug().SetMinimumLevel(LogLevel.Debug))
private static IHost CreateHost <TStartup>(int port, bool localhost, IDictionary <string, string> configuration, IClusterMemberLifetime configurator = null) where TStartup : class { return(new HostBuilder() .ConfigureWebHost(webHost => webHost.UseKestrel(options => { if (localhost) { options.ListenLocalhost(port); } else { options.ListenAnyIP(port); } }) .UseShutdownTimeout(TimeSpan.FromMinutes(2)) .ConfigureServices(services => { if (configurator != null) { services.AddSingleton(configurator); } }) .UseStartup <TStartup>() ) .ConfigureAppConfiguration(builder => builder.AddInMemoryCollection(configuration)) .ConfigureLogging(builder => builder.AddDebug().SetMinimumLevel(LogLevel.Debug)) .JoinCluster() .Build()); }
private static IHost CreateHost <TStartup>(int port, bool localhost, IDictionary <string, string> configuration, IClusterMemberLifetime configurator = null, IMemberDiscoveryService discovery = null) where TStartup : class { return(new HostBuilder() .ConfigureWebHost(webHost => webHost.UseKestrel(options => { if (localhost) { options.ListenLocalhost(port); } else { options.ListenAnyIP(port); } }) .ConfigureServices(services => { if (configurator is not null) { services.AddSingleton(configurator); } if (discovery is not null) { services.AddSingleton(discovery); } services.EnableBuffering(options => { options.MemoryThreshold = 512; }); }) .UseStartup <TStartup>() ) .UseHostOptions(new HostOptions { ShutdownTimeout = TimeSpan.FromMinutes(2) }) .ConfigureAppConfiguration(builder => builder.AddInMemoryCollection(configuration)) .ConfigureLogging(static builder => builder.AddDebug().SetMinimumLevel(LogLevel.Debug))