Skip to content

cuprated: Add graceful shutdown, pt3: Exit codes and main error propagation#590

Open
redsh4de wants to merge 6 commits into
Cuprate:mainfrom
redsh4de:feat/graceful-shutdown-pt3
Open

cuprated: Add graceful shutdown, pt3: Exit codes and main error propagation#590
redsh4de wants to merge 6 commits into
Cuprate:mainfrom
redsh4de:feat/graceful-shutdown-pt3

Conversation

@redsh4de
Copy link
Copy Markdown
Contributor

@redsh4de redsh4de commented Mar 1, 2026

What

Depends on #586

Building on part 2, this replaces hard exit and panics across cuprated's startup path with error propagation, introduces ExitCode to distinguish clean shutdowns from failures.

Based off #528
Closes #522.

Where

  • cuprated
    • main.rs - main() returns ExitCode, new main_inner() propagates all startup errors via ?, removed all process::exit(1) calls from config/init path
    • monitor.rs -TaskExecutor now has failed: Arc<OnceLock<&'static str>>, spawn_critical records the failing task on failure, typed CriticalTaskError for exit code decision
    • lib.rs - Node::wait_for_shutdown returns Result<(), CriticalTaskError>; returns CriticalTaskError if a critical task failed after the drain

How

main_inner() returns anyhow::Result<ExitCode>. Startup errors propagate to main(), which prints them with eprintln_red and returns ExitCode::FAILURE.

For runtime errors, spawn_critical records the failing task's name in a OnceLock on the TaskExecutor before triggering shutdown.wait_for_shutdown checks it after draining all tasks and returns Err(CriticalTaskError) if set - that Err flows through ? in main_inner to main(), which prints and returns ExitCode::FAILURE. Clean shutdowns return ExitCode::SUCCESS.

@github-actions github-actions Bot added A-p2p Area: Related to P2P. A-binaries Area: Related to binaries. labels Mar 1, 2026
@redsh4de redsh4de marked this pull request as draft March 1, 2026 09:47
@redsh4de redsh4de marked this pull request as ready for review March 1, 2026 14:41
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 2ae1e5e to 359d468 Compare March 15, 2026 23:23
@redsh4de redsh4de marked this pull request as draft March 17, 2026 18:12
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 359d468 to 59248a6 Compare March 18, 2026 03:38
@github-actions github-actions Bot added A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. and removed A-p2p Area: Related to P2P. labels Mar 18, 2026
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 59248a6 to 0fcfe5d Compare March 19, 2026 00:42
@github-actions github-actions Bot added the A-consensus Area: Related to consensus. label Mar 19, 2026
@redsh4de redsh4de marked this pull request as ready for review March 19, 2026 01:04
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch 2 times, most recently from 43a1bfb to 6763dd6 Compare March 20, 2026 09:14
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch 2 times, most recently from 2984084 to 6e6048d Compare March 24, 2026 22:43
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch 7 times, most recently from 2f3a078 to bb16a6c Compare April 26, 2026 14:40
@github-actions github-actions Bot added the A-storage Area: Related to storage. label Apr 26, 2026
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from bb16a6c to b211471 Compare April 26, 2026 19:53
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch 2 times, most recently from 4413d0f to 2da046f Compare May 5, 2026 17:04
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 2da046f to 8d9de5f Compare May 12, 2026 15:58
@github-actions github-actions Bot added the A-types Area: Related to types. label May 12, 2026
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch 4 times, most recently from 52f53d4 to effff4d Compare May 18, 2026 00:50
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from effff4d to 7db2652 Compare May 20, 2026 10:36
@github-actions github-actions Bot removed A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-consensus Area: Related to consensus. A-storage Area: Related to storage. labels May 20, 2026
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 7db2652 to 08a85cf Compare May 20, 2026 16:39
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch 2 times, most recently from a133385 to 80fa6a9 Compare May 31, 2026 13:05
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 80fa6a9 to eea7e15 Compare June 3, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-binaries Area: Related to binaries. A-types Area: Related to types.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cuprate Crash Starting RPC Server

1 participant