runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Improve system integration for Host

Open rosebyte opened this issue 10 months ago • 3 comments

This is a spanning issue as we have multiple issuer related to host integration with either windows service or systemd flows. We should reconsider the integration as such rather then try to solve each of these issues separately.

rosebyte avatar Jan 30 '26 12:01 rosebyte

Tagging subscribers to this area: @dotnet/area-extensions-hosting See info in area-owners.md if you want to be subscribed.

dotnet-policy-service avatar Jan 30 '26 18:01 dotnet-policy-service

Please during this activity reconsider also #77381: it was marked as a duplicated of #50019 but it isn't !!!! Note that this still apply with net 11 preview where the exception is correctly re-throwed on main program thread. But the SCM still reports the service as (gracefully) Stopped because:

  1. the SCM is notified of a completed stop https://github.com/dotnet/runtime/blob/4df47f771f0193caeeedc4d8db866c48059c5421/src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs#L378

  2. and only after the exceptions are re-throwed https://github.com/dotnet/runtime/blob/4df47f771f0193caeeedc4d8db866c48059c5421/src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs#L415-L430

IMHO to allow a correct behavior with SCM is necessary to inform in some way the WindowsServiceLifetime that something is bad in the Host (i,e, exposing _backgroundServiceExceptions in the IHost ???) so that it could react (i.e. setting an ExitCode before calling SCM Stop or not calling SCM Stop at all in this case)

beppemarazzi avatar Aug 21 '26 15:08 beppemarazzi

@beppemarazzi I agree, so I have reopened the issue.

svick avatar Aug 26 '26 14:08 svick