Skip to content

cuprated: Add graceful shutdown#585

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

cuprated: Add graceful shutdown#585
redsh4de wants to merge 23 commits intoCuprate:mainfrom
redsh4de:feat/graceful-shutdown

Conversation

@redsh4de
Copy link
Copy Markdown
Contributor

@redsh4de redsh4de commented Feb 18, 2026

What

Ports over the graceful shutdown logic from fjall-wip branch: https://github.com/Cuprate/cuprate/blob/fjall-wip/binaries/cuprated/src/monitor.rs

Depends on the embeddable version #592

Why

More idiomatic shutdown pattern, previously every exit was equivalent to a crash

Where

  • cuprated:
    • monitor.rs - TaskExecutor handle, signal handler, force-quit on double Ctrl+C
    • main.rs - wires up executor, shutdown wait loop
    • commands.rs - add Exit command
    • blockchain/manager.rs, syncer.rs - shutdown token in select loops, replace todo!() with break
    • txpool/manager.rs, incoming_tx.rs - shutdown token, change ordering by priority due to using biased
    • rpc/server.rs, rpc_handler.rs - with_graceful_shutdown, tracked spawns, carries shutdown token
    • rpc/handlers/other_json.rs - wiring for stop_daemon RPC
    • lib.rs - Node::launch returns Result, creates and distributes TaskExecutor

How

monitor.rs introduces TaskExecutor, took nomenclature inspo from reth. Instead of how reth does it though with a static, its threaded into the functions to support running multiple Node instances in the same process

All tokio::spawn replaced with TaskExecutor::spawn. Task select loops now use biased ordering with the shutdown token as higher priority.

On shutdown signal, the token is cancelled -> tasks wind down one by one, and main() waits on task tracker to finish unwinding before dropping the runtime.

Node::launch now returns Result<Self, anyhow::Error> instead of panicking on database/service init failures.

Double Ctrl+C force exits.

@github-actions github-actions bot added the A-binaries Area: Related to binaries. label Feb 18, 2026
@redsh4de redsh4de marked this pull request as draft February 18, 2026 21:43
@redsh4de redsh4de marked this pull request as draft February 18, 2026 21:43
@redsh4de redsh4de marked this pull request as ready for review February 19, 2026 15:58
@redsh4de redsh4de force-pushed the feat/graceful-shutdown branch from 83cb650 to 3e39aa8 Compare March 15, 2026 19:58
@redsh4de
Copy link
Copy Markdown
Contributor Author

Reworking this to depend on #592, ignore for now

@redsh4de redsh4de marked this pull request as draft March 17, 2026 18:12
@redsh4de redsh4de force-pushed the feat/graceful-shutdown branch from 90c91bf to 3fdda0f Compare March 17, 2026 23:16
@github-actions github-actions bot added the A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. label Mar 17, 2026
@redsh4de
Copy link
Copy Markdown
Contributor Author

Depends on #592 now.

@redsh4de redsh4de marked this pull request as ready for review March 17, 2026 23:47
@redsh4de redsh4de force-pushed the feat/graceful-shutdown branch from 3fdda0f to 9e7a372 Compare March 18, 2026 03:38
@redsh4de redsh4de force-pushed the feat/graceful-shutdown branch from 9e7a372 to 628803c 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 force-pushed the feat/graceful-shutdown branch from e950618 to 508695e Compare March 20, 2026 09:14
@redsh4de redsh4de force-pushed the feat/graceful-shutdown branch from 508695e to 31b5645 Compare March 21, 2026 10:16
@redsh4de redsh4de force-pushed the feat/graceful-shutdown branch from 31b5645 to db027a4 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.

1 participant