cuprated: Add graceful shutdown, pt3: Exit codes and main error propagation#590
Open
redsh4de wants to merge 6 commits into
Open
cuprated: Add graceful shutdown, pt3: Exit codes and main error propagation#590redsh4de wants to merge 6 commits into
main error propagation#590redsh4de wants to merge 6 commits into
Conversation
2ae1e5e to
359d468
Compare
359d468 to
59248a6
Compare
59248a6 to
0fcfe5d
Compare
43a1bfb to
6763dd6
Compare
2984084 to
6e6048d
Compare
2f3a078 to
bb16a6c
Compare
bb16a6c to
b211471
Compare
4413d0f to
2da046f
Compare
2da046f to
8d9de5f
Compare
52f53d4 to
effff4d
Compare
4 tasks
effff4d to
7db2652
Compare
7db2652 to
08a85cf
Compare
a133385 to
80fa6a9
Compare
80fa6a9 to
eea7e15
Compare
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.
What
Depends on #586
Building on part 2, this replaces hard exit and panics across cuprated's startup path with error propagation, introduces
ExitCodeto distinguish clean shutdowns from failures.Based off #528
Closes #522.
Where
cupratedmain.rs-main()returnsExitCode, newmain_inner()propagates all startup errors via?, removed allprocess::exit(1)calls from config/init pathmonitor.rs-TaskExecutornow hasfailed: Arc<OnceLock<&'static str>>,spawn_criticalrecords the failing task on failure, typedCriticalTaskErrorfor exit code decisionlib.rs-Node::wait_for_shutdownreturnsResult<(), CriticalTaskError>; returnsCriticalTaskErrorif a critical task failed after the drainHow
main_inner()returnsanyhow::Result<ExitCode>. Startup errors propagate tomain(), which prints them witheprintln_redand returnsExitCode::FAILURE.For runtime errors,
spawn_criticalrecords the failing task's name in aOnceLockon theTaskExecutorbefore triggering shutdown.wait_for_shutdownchecks it after draining all tasks and returnsErr(CriticalTaskError)if set - thatErrflows through?inmain_innertomain(), which prints and returnsExitCode::FAILURE. Clean shutdowns returnExitCode::SUCCESS.