configured user limit (128) on the number of inotify instances has been reached
问题:netcore 站点无法启动
ERROR 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.
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 Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
解决办法:
cat /proc/sys/fs/inotify/max_user_instances
ulimit -n
sudo find /proc/*/fd -lname 'anon_inode:inotify' 2>/dev/null | wc -l
cat /proc/sys/fs/file-nr
sudo sysctl fs.inotify.max_user_instances=512
nano /etc/sysctl.d/99-inotify.conf
=========================================
fs.inotify.max_user_instances = 512
=========================================
sudo sysctl -p /etc/sysctl.d/99-inotify.conf