-
Notifications
You must be signed in to change notification settings - Fork 82
feat(l2): make monitor quit #3622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
21a6df1
make monitor quit
gianbelinche 692e06b
Add abort all
gianbelinche 06b9ffc
Remove while
gianbelinche 4512ab2
Fix server shutting down without monitor
gianbelinche fd1d4c2
Fix select
gianbelinche cb4634e
Format code
gianbelinche b2eec09
move abort outride match
gianbelinche 40e8062
Merge branch 'main' into monitor-quit
gianbelinche 103cb8a
Merge branch 'main' into monitor-quit
gianbelinche 8c0577c
Merge branch 'main' into monitor-quit
gianbelinche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ use std::{ | |
sync::Arc, | ||
time::Duration, | ||
}; | ||
use tokio::sync::Mutex; | ||
use tokio::{sync::Mutex, task::JoinSet}; | ||
use tokio_util::task::TaskTracker; | ||
use tracing::{error, info}; | ||
|
||
|
@@ -155,6 +155,7 @@ impl Command { | |
|
||
// TODO: Check every module starts properly. | ||
let tracker = TaskTracker::new(); | ||
let mut join_set = JoinSet::new(); | ||
|
||
let cancel_token = tokio_util::sync::CancellationToken::new(); | ||
|
||
|
@@ -191,7 +192,7 @@ impl Command { | |
signer, | ||
peer_table.clone(), | ||
store.clone(), | ||
tracker.clone(), | ||
tracker, | ||
blockchain.clone(), | ||
) | ||
.await; | ||
|
@@ -217,20 +218,24 @@ impl Command { | |
) | ||
.into_future(); | ||
|
||
tracker.spawn(l2_sequencer); | ||
join_set.spawn(l2_sequencer); | ||
|
||
tokio::select! { | ||
_ = tokio::signal::ctrl_c() => { | ||
info!("Server shut down started..."); | ||
let node_config_path = PathBuf::from(data_dir + "/node_config.json"); | ||
info!("Storing config at {:?}...", node_config_path); | ||
cancel_token.cancel(); | ||
let node_config = NodeConfigFile::new(peer_table, local_node_record.lock().await.clone()).await; | ||
store_node_config_file(node_config, node_config_path).await; | ||
tokio::time::sleep(Duration::from_secs(1)).await; | ||
info!("Server shutting down!"); | ||
join_set.abort_all(); | ||
} | ||
_ = join_set.join_next() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When handling the first completed child task via Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
} | ||
} | ||
info!("Server shut down started..."); | ||
let node_config_path = PathBuf::from(data_dir + "/node_config.json"); | ||
info!("Storing config at {:?}...", node_config_path); | ||
cancel_token.cancel(); | ||
let node_config = | ||
NodeConfigFile::new(peer_table, local_node_record.lock().await.clone()).await; | ||
store_node_config_file(node_config, node_config_path).await; | ||
tokio::time::sleep(Duration::from_secs(1)).await; | ||
info!("Server shutting down!"); | ||
} | ||
Self::RemoveDB { datadir, force } => { | ||
Box::pin(async { | ||
|
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.