feat(server): split start wait stop lifecycle - #659
Merged
Conversation
SunSi12138
marked this pull request as ready for review
September 11, 2026 01:54
SunSi12138
commented
Sep 11, 2026
Make StartAsync/WaitForShutdownAsync/StopAsync the canonical Server lifecycle, preserve runtime-vs-connection failure domains, and explicitly observe the shared terminal cleanup task for fatal runtime paths.
SunSi12138
force-pushed
the
feat/646-server-lifecycle-dev
branch
from
September 11, 2026 10:09
9429d3c to
a7f6850
Compare
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #646
Summary
RunAsyncwithStartAsync,WaitForShutdownAsync, andStopAsyncas the single canonical lifecycle model.SharpLinkServerLifecycleStateindependently from localHealthStatus.SharpLinkServerown and observe its accept loop and fatal runtime tasks after startup._runTask,_runCts, andObserveRunTaskAsynclifetime model.RunAsync.Lifecycle semantics
StartAsyncreturns only after the Server-owned accept infrastructure is established and lifecycle is published asRunning; an immediate accept/startup failure is propagated to the startup caller.WaitForShutdownAsyncis a pure terminal observer. Its token cancels only that caller's wait and never initiates shutdown.StopAsynccreates or joins one shared Server-owned drain/cleanup operation. Caller cancellation cancels only the caller's wait, not the shared shutdown.StopAsyncfromCreatedreaches a real terminalStoppedstate.Faulted; Stop/Wait expose the same terminal failure.Failure domains
_stopTaskremains faulted/joinable so laterStopAsynccallers still receive the same terminal failure, whileWaitForShutdownAsyncremains an independent terminal observer.Generic Host
IHostedService.StartAsyncawaitsserver.StartAsyncand publishes readiness only after startup succeeds.IHostedService.StopAsyncjoinsserver.StopAsyncwithout passing the Host caller token into the Server-owned stop operation.Validation
Development validation was run from exact
devbase2f16532e4c18acff922d208eb262aec4999b33ac:dotnet format whitespace+git diff --check: passedDev validation run:
34543816894.Review follow-up validation:
FatalRuntimeFailureWaitOnlyShouldObserveOwnedTerminalCleanupTask, coveringStartAsync -> WaitForShutdownAsyncwithout a follow-upStopAsyncand asserting the Server-owned terminal cleanup observer completes successfully;git diff --check, and version/schema guard: passed;Final exact-head PR CI on
a7f685052a8c18b01b7fc8d9d3e89f2f40280ca5is green:Final branch is one commit ahead of exact
devbase and contains no temporary review workflow files. No version/schema bump was introduced.