HostingExtensions.RunUntilShutdownAsync method
Starts server, blocks until the process receives Ctrl-C / SIGTERM (or stopToken is cancelled), then calls StopAsync and disposes the host.
public static Task RunUntilShutdownAsync(this KestrunHost server, bool configureConsole = true,
Encoding? consoleEncoding = null, Action? onStarted = null,
Action<Exception>? onShutdownError = null, CancellationToken stopToken = default)
Remarks
Intended for console apps’ Main; keeps boiler-plate out of every sample you write.
If configureConsole is true (default) the method hooks CancelKeyPress. In a service/daemon scenario you can pass false and supply your own cancellation token.
See Also
- class KestrunHost
- class HostingExtensions
- namespace Kestrun.Utilities