Skip to content

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

Open
redsh4de wants to merge 27 commits intoCuprate:mainfrom
redsh4de:feat/graceful-shutdown-pt3
Open

cuprated: Add graceful shutdown, pt3: Exit codes and main error propagation#590
redsh4de wants to merge 27 commits intoCuprate: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<AtomicBool> flag, spawn_critical sets it on error, has_failed() function for exit code decision

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 sets an AtomicBool flag on the TaskExecutor before triggering shutdown. After the runtime is dropped, main() reads has_failed() to decide between ExitCode::SUCCESS and ExitCode::FAILURE.

@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 from 0fcfe5d to 43a1bfb Compare March 19, 2026 07:48
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 43a1bfb to 6763dd6 Compare March 20, 2026 09:14
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 6763dd6 to 2984084 Compare March 21, 2026 10:16
@redsh4de redsh4de force-pushed the feat/graceful-shutdown-pt3 branch from 2984084 to 6e6048d Compare March 24, 2026 22:43
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-consensus Area: Related to consensus. A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cuprate Crash Starting RPC Server

1 participant