Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Default timeout for IHost.StopAsync. Create Host with DI.#1237

Merged
Tratcher merged 1 commit intodevfrom
tratcher/timeout
Oct 17, 2017
Merged

Default timeout for IHost.StopAsync. Create Host with DI.#1237
Tratcher merged 1 commit intodevfrom
tratcher/timeout

Conversation

@Tratcher
Copy link
Member

@Tratcher Tratcher commented Oct 13, 2017

#1208 This ports the default shutdown timeout from WebHost to Host. It also introduces HostOptions for configuring the value, and changes Host to be instantiated via DI.

I recommend the https://github.com/aspnet/Hosting/pull/1237/files?w=1 view when reviewing Host.cs

@Tratcher Tratcher added this to the 2.1.0 milestone Oct 13, 2017
@Tratcher Tratcher self-assigned this Oct 13, 2017
services.AddSingleton(_appConfiguration);
services.AddSingleton<IApplicationLifetime, ApplicationLifetime>();
services.AddSingleton<IHostLifetime, ProcessLifetime>();
services.AddSingleton<IHost, Host>();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't these need to be after AddOptions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not order sensitive.

@Tratcher Tratcher requested a review from halter73 October 16, 2017 17:38
public Host(IServiceProvider services, IApplicationLifetime applicationLifetime, ILogger<Host> logger,
IHostLifetime hostLifetime, IOptions<HostOptions> options)
{
if (options == null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Might be worth guarding agains and NRE in StopAsync by ensuring options.Value isn't null. ConsoleLifetime does options?.Value ?? throw new ArgumentNullException(nameof(options)); which I think is reasonable enough.

}
}

[Fact]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Shorten the Task.Delay(TimeSpan.FromSeconds(8)) in HostStopAsyncCanBeCancelledEarly to be less than 5 seconds.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants