Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • wmotr 16 posts 146 karma points
    Oct 22, 2022 @ 10:52
    wmotr
    0

    Troubles starting Umbraco in Kubernetes : File Watchers

    Hi,

    I am using a custom kubernetes based on talos (bare-metal kubernetes deployment).

    by default the file watchers limit is 128.

    I am trying to run this container with a full stateless design (media files in a minio cluster) to improve scaling and release management.

    I am stating the container with config "reloadOnChange:false" in the appsettings config :

    builder.AddJsonFile("appsettings.json", false, false)
        .AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: false)
        .AddJsonFile("appsettings.local.json", optional: true, reloadOnChange: false)
        .AddEnvironmentVariables();
    

    but since there is a InMemoryFactory constructor :

    // BEWARE! if the watcher is not properly released then for some reason the
                // BuildManager will start confusing types - using a 'registered object' here
                // though we should probably plug into Umbraco's MainDom - which is internal
                _hostingLifetime.RegisterObject(this);
                _watcher = new FileSystemWatcher(_pureLiveDirectory.Value);
                _watcher.Changed += WatcherOnChanged;
                _watcher.EnableRaisingEvents = true;
    

    in :

    namespace Umbraco.Cms.Web.Common.ModelsBuilder
    {
        internal class InMemoryModelFactory : IAutoPublishedModelFactory, IRegisteredObject, IDisposable
    

    the pods starts and crash with error :

    System.InvalidOperationException: The exception handler configured on ExceptionHandlerOptions produced a 404 status response. This InvalidOperationException containing the original exception was thrown since this is often due to a misconfigured ExceptionHandlingPath. If the exception handler is expected to return 404 status responses then set AllowStatusCode404Response to true.
     ---> System.IO.IOException: The configured user limit (128) on the number of inotify instances has been reached, or the per-process limit on the number of open file descriptors has been reached.
    
       at System.IO.FileSystemWatcher.StartRaisingEvents()
    
       at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
       at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
       at Umbraco.Cms.Web.Common.ModelsBuilder.InMemoryModelFactory..ctor(Lazy`1 umbracoServices, IProfilingLogger profilingLogger, ILogger`1 logger, IOptionsMonitor`1 config, IHostingEnvironment hostingEnvironment, IApplicationShutdownRegistry hostingLifetime, IPublishedValueFallback publishedValueFallback, ApplicationPartManager applicationPartManager)
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`
    

    Is it possible to override this configuration ?

    Regards, and thanks for your help !

  • wmotr 16 posts 146 karma points
    Oct 22, 2022 @ 11:04
    wmotr
    0

    Hi !

    Seems to be better with this docker file :

    FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine  AS base
    WORKDIR /src
    RUN apk add --no-cache icu-libs
    ENV ASPNETCORE_ENVIRONMENT Production
    ENV ASPNETCORE_URLS http://+:8000
    ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
    EXPOSE 8000
    
    FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
    WORKDIR /src
    RUN apk add --no-cache icu-libs
    COPY ["umbraco.sln", "./"]
    COPY ["umbraco.web/umbraco.web.csproj", "./umbraco.web/umbraco.web.csproj"]
    COPY ["umbraco.custom/umbraco.custom.csproj", "./umbraco.custom/umbraco.custom.csproj"]
    COPY ["umbraco.models/umbraco.models.csproj", "./umbraco.models/umbraco.models.csproj"]
    
    RUN dotnet restore "umbraco.sln"
    RUN dotnet dev-certs https --trust
    
    COPY . .
    WORKDIR "/src/"
    
    RUN dotnet build "umbraco.sln" -c Release -o /app/build
    
    FROM build AS publish
    RUN dotnet publish "umbraco.sln" -c Release -o /app/publish
    
    
    FROM base AS final
    ENV DOTNET_USE_POLLING_FILE_WATCHER=true
    ENV DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE=false
    ENV DOTNET_WATCH_SUPPRESS_MSBUILD_INCREMENTALISM=true
    ENV DOTNET_RUNNING_IN_CONTAINER=true
    RUN echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf 
    WORKDIR /app
    COPY --from=publish /app/publish . 
    RUN sh /app/datadog/createLogPath.sh
    CMD [ "sysctl -p" ]
    ENTRYPOINT ["dotnet", "umbraco.web.dll"]
    
  • wmotr 16 posts 146 karma points
    Oct 22, 2022 @ 11:20
    wmotr
    0

    in fact, it does not :( ...

    still working on it . trying to find an ENV variable that could override that behavior, if someone has any idea ?

    regards

  • wmotr 16 posts 146 karma points
    Mar 17, 2023 @ 10:51
    wmotr
    0

    Since Latests Umbraco versions, it seems to be working.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies