Skip to content

Commit d596183

Browse files
authored
Add some shadow copy info (#35201)
1 parent d39e1ed commit d596183

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Servers/IIS/AspNetCoreModuleV2/AspNetCore/applicationinfo.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,26 @@ APPLICATION_INFO::ShutDownApplication(const bool fServerInitiated)
251251
}
252252
}
253253

254+
/* Overview of shadow copy logic when enabled. See https://github.com/dotnet/aspnetcore/pull/28357 for more context
255+
256+
* On first request, ANCM goes through its startup sequence, starting dotnet and sending the request into managed code. During this sequence,
257+
* ANCM will copy the contents of the app directory to another directory which is user specified. The path to this directory can be absolute or relative.
258+
259+
* Logs and log files will be written to the app directory rather than the shadow copy directory. app_offline will also only be watched in the app directory.
260+
* The current directory will be set to the app directory as well as the AppContext.BaseDirectory.
261+
262+
* On publish of new content to the app directory, ANCM will start debouncing file change notifications for dlls, waiting for a steady state.
263+
* This is done by resetting a timer each time a dll is changed, eventually triggering the timer once there are no dll changes. Afterwards, shutdown is started,
264+
* causing the process to recycle.
265+
266+
* Subfolders are created under the user specified shadowCopyDirectory, where the highest int value directory name will be used each time.
267+
* It will start at subdirectory with name '0' and increment from there. On shutdown, because dlls are still locked by the running process,
268+
* we need to copy dlls to a different directory than what is currently running in the app. So in the case where the directory name is '0',
269+
* we will create a directory name '1' and write the contents there. Then on app start, it will pick the directory name '1' as it's the highest value.
270+
271+
* Other directories in the shadow copy directory will be cleaned up as well. Following the example, after '1' has been selected as the directory to use,
272+
* we will start a thread that deletes all other folders in that directory.
273+
*/
254274
std::filesystem::path
255275
APPLICATION_INFO::HandleShadowCopy(const ShimOptions& options, IHttpContext& pHttpContext)
256276
{

0 commit comments

Comments
 (0)