From 9b15523ee236d7ee8cb31b74d42cddf43d9061fd Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Wed, 17 Apr 2024 20:32:15 +0100 Subject: [PATCH] feat: provide `--interval` arg for `upgrade` cmd This was another community feedback request. As with the `start` command, a time-based interval is applied between each node being upgraded. We will probably need something more sophisticated, but this simple mechanism should hopefully be useful for now. --- sn_node_manager/src/bin/cli/main.rs | 7 +++++++ sn_node_manager/src/cmd/node.rs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/sn_node_manager/src/bin/cli/main.rs b/sn_node_manager/src/bin/cli/main.rs index 98ba036dc4..cbcc3939b6 100644 --- a/sn_node_manager/src/bin/cli/main.rs +++ b/sn_node_manager/src/bin/cli/main.rs @@ -284,6 +284,11 @@ pub enum SubCmd { /// Required if we want to downgrade, or for testing purposes. #[clap(long)] force: bool, + /// An interval applied between upgrading each service. + /// + /// Units are milliseconds. + #[clap(long, default_value_t = 200)] + interval: u64, /// Provide a path for the safenode binary to be used by the service. /// /// Useful for upgrading the service using a custom built binary. @@ -764,6 +769,7 @@ async fn main() -> Result<()> { SubCmd::Upgrade { do_not_start, force, + interval, path, peer_id: peer_ids, service_name: service_names, @@ -775,6 +781,7 @@ async fn main() -> Result<()> { do_not_start, path, force, + interval, peer_ids, provided_env_variable, service_names, diff --git a/sn_node_manager/src/cmd/node.rs b/sn_node_manager/src/cmd/node.rs index da12575627..52091890f1 100644 --- a/sn_node_manager/src/cmd/node.rs +++ b/sn_node_manager/src/cmd/node.rs @@ -32,6 +32,7 @@ use sn_service_management::{ }; use sn_transfers::HotWallet; use std::{io::Write, net::Ipv4Addr, path::PathBuf, str::FromStr}; +use tracing::debug; pub async fn add( count: Option, @@ -264,6 +265,7 @@ pub async fn start( let service = NodeService::new(node, Box::new(rpc_client)); let mut service_manager = ServiceManager::new(service, Box::new(ServiceController {}), verbosity.clone()); + debug!("Sleeping for {} milliseconds", interval); std::thread::sleep(std::time::Duration::from_millis(interval)); match service_manager.start().await { Ok(()) => { @@ -363,6 +365,7 @@ pub async fn upgrade( do_not_start: bool, custom_bin_path: Option, force: bool, + interval: u64, peer_ids: Vec, provided_env_variables: Option>, service_names: Vec, @@ -449,6 +452,9 @@ pub async fn upgrade( )); } } + + debug!("Sleeping for {} milliseconds", interval); + std::thread::sleep(std::time::Duration::from_millis(interval)); } node_registry.save()?;