smtp4dev icon indicating copy to clipboard operation
smtp4dev copied to clipboard

Disable file watcher - The configured user limit (128) on the number of inotify instances has been reached

Open EtienneBruines opened this issue 1 year ago • 3 comments

Follow-up on https://github.com/rnwood/smtp4dev/issues/1200

We are running short-lived smtp4dev instances in a container environment in our CI tests. Sometimes starting smtp4dev does not work. Logs:

2024-10-07T03:16:57.219584091Z smtp4dev version 3.6.1+5e577a8b4152ceb7276a5b8d4432430c9ff9055d
2024-10-07T03:16:57.220143267Z https://github.com/rnwood/smtp4dev
2024-10-07T03:16:57.220293099Z .NET Core runtime version: .NET 8.0.4
2024-10-07T03:16:57.225646355Z 
2024-10-07T03:16:57.225666483Z  > For help use argument --help
2024-10-07T03:16:57.225669889Z 
2024-10-07T03:16:57.226773483Z Install location: /
2024-10-07T03:16:57.277489530Z DataDir: /smtp4dev
2024-10-07T03:16:57.288689842Z Default settings file: /app/appsettings.json
2024-10-07T03:16:57.288833213Z User settings file: /smtp4dev/appsettings.json
2024-10-07T03:16:57.299728290Z A unhandled exception occurred.
2024-10-07T03:16:57.299752536Z 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.
2024-10-07T03:16:57.299758367Z    at System.IO.FileSystemWatcher.StartRaisingEvents()
2024-10-07T03:16:57.299761833Z    at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
2024-10-07T03:16:57.299765680Z    at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
2024-10-07T03:16:57.299769027Z    at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
2024-10-07T03:16:57.299771792Z    at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
2024-10-07T03:16:57.299774417Z    at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
2024-10-07T03:16:57.299777683Z    at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
2024-10-07T03:16:57.299780969Z    at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
2024-10-07T03:16:57.299783945Z    at Rnwood.Smtp4dev.Program.<>c__DisplayClass8_0.<BuildWebHost>b__0(HostBuilderContext hostingContext, IConfigurationBuilder configBuilder) in /home/vsts/work/1/s/Rnwood.Smtp4dev/Program.cs:line 175
2024-10-07T03:16:57.299788323Z    at Microsoft.Extensions.Hosting.HostBuilder.InitializeAppConfiguration()
2024-10-07T03:16:57.299792000Z    at Microsoft.Extensions.Hosting.HostBuilder.Build()
2024-10-07T03:16:57.299795537Z    at Rnwood.Smtp4dev.Program.BuildWebHost(String[] args, CommandLineOptions cmdLineOptions, MapOptions`1 commandLineOptions) in /home/vsts/work/1/s/Rnwood.Smtp4dev/Program.cs:line 222
2024-10-07T03:16:57.299798803Z    at Rnwood.Smtp4dev.Program.StartApp(IEnumerable`1 args, Boolean isDesktopApp, Action`1 fixedOptions) in /home/vsts/work/1/s/Rnwood.Smtp4dev/Program.cs:line 104
2024-10-07T03:16:57.299802460Z    at Rnwood.Smtp4dev.Program.Main(String[] args) in /home/vsts/work/1/s/Rnwood.Smtp4dev/Program.cs:line 44

The issue is here: https://github.com/rnwood/smtp4dev/blob/fcae595f3c6434cbdabc662c23797703ece1f216/Rnwood.Smtp4dev/Program.cs#L160

Is there any way we can configure this reloadOnChange: true via environment variables? To set this to false? There is no need for file watchers in automated tests.

(Ideally this would also apply to the user config files a few lines later.)

Thanks!

EtienneBruines avatar Oct 07 '24 08:10 EtienneBruines

Related issue: https://github.com/dotnet/dotnet-docker/issues/3546

rnwood avatar Oct 17 '24 18:10 rnwood

PR #1564 created. This turns off the use of inotify for the Linux container images.

This needs some wider testing before merging. Feedback invited from everyone. You can pull down the tag from the PR to test.

rnwood avatar Oct 17 '24 18:10 rnwood

Docker hub tag is: 3.7.0-ci20241017100

rnwood avatar Oct 17 '24 18:10 rnwood