I need to notify systemd
that my service has started up successfully, and a task it needs to run after startup requires that the server is already listening
On .Net Core 1.x
it is safe to just run IWebHost.Start()
and assume that the server is initialized afterwards (instead of Run()
that blocks the thread). Check the source.
var host = new WebHostBuilder()
.UseKestrel()
(...)
.Build();
host.Start();
If you are using .NET Core 2.0 Preview 1
(or later), the source is different, the synchronous method is not available anymore so you should await IWebHost.StartAsync()
and assume everything is ready afterwards.