You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Host] Allow disabling reloadOnChange for Host's CreateDefaultBuilder #2939
Summary
So I've been running into a problem with the builder in (previously WebHost) Host causing issues with older or default-configured instances of Systemd on CentOS or other Linux distros, and the culprit appears to be a collision of the live reloading mechanism, and Systemd running registered services with / as the context root.
So this is a feature as well as a fix for a (rare?) problem.
Issue Stack
Host.CreateDefaultBuilder() does a significant amount of Bootstrapping and configuration that is nice to have, and to not have to recreate. But internally it makes two calls to AddJsonFile with reloadOnChange hard coded to true. This is to set up the default appsettings.json file.
On older versions of .NET Core the filesystem reload mechanism was polling or something, but in 3.x this appears to have changed to a filesystem notification mechanism. So the update from 2.x to 3.x broke this for us as this ties more deeply into filesystem perms.
So default builder winds up trying to subscribe to notifications on /, and will get 'Access to the path /proc/13549/map_files is denied' or similar errors on startup.
Proposed Solution
Being that this context root is a default behavior of SystemD, but applications seem to otherwise work fine, I'm proposing a transparent environment flag that allows reloadOnChange to be disabled, and falls back to the old behavior (true) if undefined. This way if you need to you can disable the live reload and otherwise leave everyone else alone.
I'm opening and cross linking a PR with the code changes as well as two (annoyingly long) tests that assert the two different cases work.
changed the title [-][DefaultBuilder] Allow disabling reloadOnChange for WebHost's CreateDefaultBuilder[/-][+][Host] Allow disabling reloadOnChange for Host's CreateDefaultBuilder[/+]on Feb 5, 2020
Activity
Tratcher commentedon Feb 5, 2020
Moving this to Extensions since WebHost has been replaced by the generic Host.
kjerk commentedon Feb 5, 2020
Reworking the PR from before the move. Thanks for letting me know about the code having migrated.
Edit: Done, added PR #2940
[-][DefaultBuilder] Allow disabling reloadOnChange for WebHost's CreateDefaultBuilder[/-][+][Host] Allow disabling reloadOnChange for Host's CreateDefaultBuilder[/+]