cuprated: Add graceful shutdown#585
Merged
Merged
Conversation
83cb650 to
3e39aa8
Compare
Contributor
Author
|
Reworking this to depend on #592, ignore for now |
90c91bf to
3fdda0f
Compare
Contributor
Author
|
Depends on #592 now. |
9e7a372 to
628803c
Compare
31b5645 to
db027a4
Compare
b9fb288 to
96b81dd
Compare
96b81dd to
c854901
Compare
c854901 to
8b853be
Compare
69ba849 to
cc90a18
Compare
a2e0d9a to
e0b279c
Compare
4 tasks
e0b279c to
85388a0
Compare
Member
SyntheticBird45
left a comment
There was a problem hiding this comment.
I let a few comment but overall lgtm
1fbee3c to
f485cff
Compare
f485cff to
00e6773
Compare
SyntheticBird45
approved these changes
May 19, 2026
Boog900
approved these changes
May 19, 2026
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
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-TaskExecutorhandle (cancellation token + task tracker)config.rs-target_max_memory/fjall_cache_size/block_downloader_configreturn Result instead of panicking on unresolved memorymain.rs- wires up executor, OS signal handler, double-Ctrl+C force exit, shutdown wait loopcommands.rs- addExitcommandblockchain/manager.rs, syncer.rs- shutdown token inselectloops, replacetodo!()withbreaktxpool/manager.rs, incoming_tx.rs- shutdown token, change ordering by priority due to usingbiasedrpc/server.rs-with_graceful_shutdownon axum, tracked spawns, shutdown token plumbed throughrpc/handlers/other_json.rs- wiring forstop_daemonRPClib.rs-Node::launchreturnsResult, creates and distributesTaskExecutor, Drop implstorage/blockchain:database.rs- detach drop-loginfo!from caller spanHow
monitor.rsintroducesTaskExecutor, took nomenclature inspo from reth. Instead of how reth does it though with a static, its threaded into the functions to support running multipleNodeinstances in the same processAll
tokio::spawnreplaced withTaskExecutor::spawn. Task select loops now usebiasedordering 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::launchnow returnsResult<Self, anyhow::Error>instead of panicking on database/service init failures.Double Ctrl+C force exits.