.net core 发布linux报错“The configured user limit (128) on the number of inotify instances has been reached”
var builder = new ConfigurationBuilder()
.AddJsonFile($"appsettings.json", true, true);
You are creating file watchers, every time you access an setting. The 3rd parameter is reloadOnChange.
You have to make sure,
var configuration = builder.Build()
is only called once in your application and store it in a place where you can access it (preferably AVOID static fields for it).
Or just disable the file watcher.
var builder = new ConfigurationBuilder()
.AddJsonFile($"appsettings.json", true, false);
or cleaner:
var builder = new ConfigurationBuilder()
.AddJsonFile($"appsettings.json", optional: true, reloadOnChange: false);
Best way is to abstract hat behind an interface and use dependency injection.
public interface IConfigurationManager
{
T GetAppConfig<T>(string key, T defaultValue = default(T));
}
public class ConfigurationManager : IConfigurationManager
{
private readonly IConfigurationRoot config;
public ConfigurationManager(IConfigurationRoot config)
=> this.config ?? throw new ArgumentNullException(nameof(config));
public T GetAppConfig<T>(string key, T defaultValue = default(T))
{
T setting = (T)Convert.ChangeType(configuration[key], typeof(T));
value = setting;
if (setting == null)
value = defaultValue;
}
}
Then instantiate and register it
services.AddSingleton<IConfigurationManager>(new ConfigurationManager(this.Configuration));
and inject it into your services via constructor
.net core 发布linux报错“The configured user limit (128) on the number of inotify instances has been reached”的更多相关文章
- 单元测试过多,导致The configured user limit (128) on the number of inotify instances has been reached.
最近在一个asp.net core web项目中使用TDD的方式开发,结果单元测试超过128个之后,在CI中报错了:"The configured user limit (128) on t ...
- VSCode 出现错误 System.IO.IOException: The configured user limit (128) on the number of inotify instances has been reached.
方案一: sudo vim /etc/sysctl.conf 增加下面内容(环境变量) fs.inotify.max_user_watches = 1638400 fs.inotify.max_use ...
- 【docker】【redis】2.docker上设置redis集群---Redis Cluster部署【集群服务】【解决在docker中redis启动后,状态为Restarting,日志报错:Configured to not listen anywhere, exiting.问题】【Waiting for the cluster to join...问题】
参考地址:https://www.cnblogs.com/zhoujinyi/p/6477133.html https://www.cnblogs.com/cxbhakim/p/9151720.htm ...
- eclipse发布项目报错:Multiple Contexts hava a path of “/xxx“
你的位置:首页 > Java编程 > eclipse发布项目报错:Multiple Contexts hava a path of “/xxx“ eclipse发布项目报错:Multipl ...
- 64位linux报错Could not initialize class java.awt.image.BufferedImage
最近碰到一个问题: 64位linux报错Could not initialize class java.awt.image.BufferedImage 在WIN平台下运行正常BufferedImage ...
- Linux报错之ping: www.baidu.com: Name or service not known
Linux报错之ping: www.baidu.com: Name or service not known 出现这个以后,首先去ping下主机Ip,发现能ping通,但是出现另一个问题Destina ...
- Linux报错
Linux报错 ------------------- 在VMware虚拟机中配置yum源时,执行 mount /dev/cdrom /mnt/cdrom 出现 mount: no medium fo ...
- iis 7上发布mvc报错:403.14-Forbidden Web 服务器被配置为不列出此目录的内容
iis 7上发布mvc报错:403.14-Forbidden Web 服务器被配置为不列出此目录的内容 提示里面的解决方法是: 如果不希望启用目录浏览,请确保配置了默认文档并且该文件存在. 使用 II ...
- FXP登录Linux报错
1.用FXP登录Linux报错: [info] subsystem request for sftp failed, subsystem not found.[右] [execute] /usr/li ...
随机推荐
- vuex中store保存的数据,刷新页面会清空
用vuex,项目中需要记录一些状态,来判断页面是否为登录状态和页面是否可被编辑,此时用到了vuex中的store来存储一个状态. //首先 安装vuex npm install vuex --save ...
- dskinlite(uieasy mfc界面库)使用记录4:listbox测试
先看效果图: xml代码: 作者qq:80101277,dskinlite交流qq群:138231653 <window name="listbox1" type=" ...
- jquery倒计时按钮常用于验证码倒计时
<!doctype html><html><head> <meta charset="utf-8"> <title>jq ...
- python基础入门之对文件的操作
**python**文件的操作1.打开文件 打开文件:open(file,mode='r') file:操作文件的路径加文件名 #绝对路径:从根目录开始的 #相对路径:从某个路径开始 mode:操作文 ...
- jquery基础知识随笔
<html> <head> <script type="text/javascript" src="/jquery/jquery.js&qu ...
- cookie存储
cookie就是用来存储数据的 cookie先分装函数 这是用来存数据的函数 function setCookie(name,value,iDay){ if(iDay){ var oDate = ne ...
- mysql & sqlserver语法差异
isnull vs ifnull dateadd vs date_add limit vs top
- Oracle 12c 安装问题及解决方案
1. 介绍 今天在我的开发电脑上安装Oracle12c,电脑环境是windows10家庭中文版,安装的Oracle数据库版本Oracle(12.1.0.2.0) - Standard Edition ...
- centos7 启动tomcat卡盾
vim $JAVA_HOME/jre/lib/security/java.security securerandom.source=file:/dev/random 改为 securerandom.s ...
- eclipse中opencv配置
1.打开Eclipse,Window->preferences 2.进入preferences后,找到Java->Build Path->User Libraries,点击New 在 ...