Full width home advertisement

Post Page Advertisement [Top]


What went wrong?

One of our develop issued with high CPU usage of our netcore web application. Sometimes application catches a lot of filesystem changes from %HOME% folder and watches all files inside.I attached to his application with dnSpy and when problem detected again I paused it in debugger. As you can see, web application reacts to filesystem changes:



I started to investigate and found that CreateDefaultBuilder creates new FileSystemWatcher in it's internal code. FileSystemWatcher are created to watch appsettings*.json files:


config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);


https://github.com/aspnet/MetaPackages/blob/f245512f6e68d65309b65528d479f32b34c67718/src/Microsoft.AspNetCore/WebHost.cs#L160

Solution

I took all code from CreateDefaultBuilder(), except lines that watches filesystem changes of appsettings.json. I rewrote them with reloadOnChange: false

Комментариев нет:

Отправить комментарий

Bottom Ad [Post Page]

| Дизайн Colorlib