• Net Core linux docker 部署异常


    环境:

      .NET Core 3.1

      Linux + Docker

    问题:

    近期发布后发现,服务经常需要多次重启才能启动。观察日志发现异常:

      Unhandled exception. 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.

    尝试网上很多方法后,还是出现了问题,通过断点发现 Configuration 的 ReloadOnChange 不管怎么样都是 true,后面通过如下方法解决了

      

      webBuilder.ConfigureAppConfiguration((hostingContext, config) =>
                        {
                            IHostEnvironment env = hostingContext.HostingEnvironment;
    
                  //调用Clear 会报错,因时间就没有深查了 config.Sources.ForEach(source
    => { if (source is JsonConfigurationSource) { var jsonConfigurationSource = (JsonConfigurationSource)source; jsonConfigurationSource.ReloadOnChange = false; } }); config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: false); if (env.IsDevelopment() && !string.IsNullOrEmpty(env.ApplicationName)) { var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName)); if (appAssembly != null) { config.AddUserSecrets(appAssembly, optional: true); } } config.AddEnvironmentVariables(); if (args != null) { config.AddCommandLine(args); } }).UseStartup<Startup>();
  • 相关阅读:
    单例模式(Singleton)
    建造者模式(Builder和Director)
    原型模式(Prototype)
    备忘录模式(Memento)
    观察者模式(Observer)
    工厂模式(Factory)
    状态模式(State)
    模板方法模式(Template Method)
    策略模式(Strategy)
    微信小程序------小程序初步学习
  • 原文地址:https://www.cnblogs.com/zhihang/p/14803698.html
Copyright © 2020-2023  润新知