Skip to content

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

Merged
Boog900 merged 1 commit into
Cuprate:mainfrom
redsh4de:feat/graceful-shutdown-pt3
Aug 24, 2026
Merged

Boog900 merged 1 commit into
Cuprate:mainfrom
redsh4de:feat/graceful-shutdown-pt3

Conversation

@redsh4de

@redsh4de redsh4de commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

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 3 times, most recently from 80fa6a9 to eea7e15 Compare June 3, 2026 12:54
@redsh4de
redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from eea7e15 to b5e4c94 Compare June 15, 2026 09:32
@redsh4de
redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from b5e4c94 to b67d489 Compare July 20, 2026 23:37
@github-actions github-actions Bot added the A-p2p Area: Related to P2P. label Jul 20, 2026
@redsh4de
redsh4de force-pushed the feat/graceful-shutdown-pt3 branch 3 times, most recently from 4181eba to 38c971f Compare July 27, 2026 06:01
@redsh4de
redsh4de force-pushed the feat/graceful-shutdown-pt3 branch 3 times, most recently from 6590ab4 to 74462b8 Compare August 5, 2026 21:45
@Boog900 Boog900 added this to the cuprated v0.1.0 preview 2 milestone Aug 20, 2026
@redsh4de
redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 74462b8 to 83a8084 Compare August 22, 2026 08:34
@github-actions github-actions Bot added A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-workspace Area: Changes to a root workspace file or general repo file. A-consensus Area: Related to consensus. labels Aug 22, 2026
@redsh4de
redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 83a8084 to 1f059d7 Compare August 22, 2026 12:34
@redsh4de
redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 1f059d7 to b649a81 Compare August 24, 2026 18:15
@github-actions github-actions Bot removed A-p2p Area: Related to P2P. A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-workspace Area: Changes to a root workspace file or general repo file. A-consensus Area: Related to consensus. A-types Area: Related to types. labels Aug 24, 2026
@Boog900
Boog900 merged commit 52d9580 into Cuprate:main Aug 24, 2026
22 checks passed
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cuprate Crash Starting RPC Server

2 participants