Skip to content

[Host] Allow disabling reloadOnChange for Host's CreateDefaultBuilder #2939

Closed

Description

@kjerk

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.
  • If you have a production release pipeline or are in any way winding up with ASP.NET Core applications running on SystemD, by default these services are run with / as the application root.
  • 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.

Activity

  1. Tratcher commented on Feb 5, 2020

    @Tratcher
    Member

    Moving this to Extensions since WebHost has been replaced by the generic Host.

  2. transferred this issue fromdotnet/aspnetcoreon Feb 5, 2020
  3. kjerk commented on Feb 5, 2020

    @kjerk
    Author

    Reworking the PR from before the move. Thanks for letting me know about the code having migrated.
    Edit: Done, added PR #2940

  4. changed the title [-][DefaultBuilder] Allow disabling reloadOnChange for WebHost's CreateDefaultBuilder[/-] [+][Host] Allow disabling reloadOnChange for Host's CreateDefaultBuilder[/+] on Feb 5, 2020
  5. added this to the Backlog milestone on Feb 7, 2020
  6. ghost locked as resolved and limited conversation to collaborators on Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions