Skip to content

Add some shadow copy info #35201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,26 @@ APPLICATION_INFO::ShutDownApplication(const bool fServerInitiated)
}
}

/* Overview of shadow copy logic when enabled. See https://github.com/dotnet/aspnetcore/pull/28357 for more context

* On first request, ANCM goes through its startup sequence, starting dotnet and sending the request into managed code. During this sequence,
* 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.

* 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.
* The current directory will be set to the app directory as well as the AppContext.BaseDirectory.

* On publish of new content to the app directory, ANCM will start debouncing file change notifications for dlls, waiting for a steady state.
* 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,
* causing the process to recycle.

* Subfolders are created under the user specified shadowCopyDirectory, where the highest int value directory name will be used each time.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that if directory '1' exists but '0' doesn't, '0' will be used and '1' will be deleted. Is that the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question, I'll add a new shadowcopy test to see what happens, I know that it does go and clean up old directories, but I'm not sure if it will look for gaps like that, I'd sort of assume it would use '2' to keep increasing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah see #35249 for the new test so the behavior is '1' will be used, and then '2' will be used on the next modification, so its always incrementally increasing using the highest integer for the next location (copied on shutdown).

* It will start at subdirectory with name '0' and increment from there. On shutdown, because dlls are still locked by the running process,
* 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',
* 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.

* 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,
* we will start a thread that deletes all other folders in that directory.
*/
std::filesystem::path
APPLICATION_INFO::HandleShadowCopy(const ShimOptions& options, IHttpContext& pHttpContext)
{
Expand Down