diff --git a/nym-node-status-agent/run.sh b/nym-node-status-agent/run.sh index e5a0dd5155..5054a90825 100755 --- a/nym-node-status-agent/run.sh +++ b/nym-node-status-agent/run.sh @@ -16,7 +16,7 @@ function copy_gw_probe() { pushd $gateway_probe_src cargo build --release --package nym-gateway-probe cp target/release/nym-gateway-probe "$crate_root" - $NYM_GATEWAY_PROBE --version + $crate_root/nym-gateway-probe --version popd } diff --git a/nym-node-status-api/src/cli/mod.rs b/nym-node-status-api/src/cli/mod.rs index 3811137a9e..84ee86577f 100644 --- a/nym-node-status-api/src/cli/mod.rs +++ b/nym-node-status-api/src/cli/mod.rs @@ -53,6 +53,22 @@ pub(crate) struct Cli { /// Connection url for the database. #[clap(long, env = "DATABASE_URL")] pub(crate) database_url: String, + + #[clap( + long, + default_value = "600", + env = "NODE_STATUS_API_MONITOR_REFRESH_INTERVAL" + )] + #[arg(value_parser = parse_duration)] + pub(crate) monitor_refresh_interval: Duration, + + #[clap( + long, + default_value = "600", + env = "NODE_STATUS_API_TESTRUN_REFRESH_INTERVAL" + )] + #[arg(value_parser = parse_duration)] + pub(crate) testruns_refresh_interval: Duration, } fn parse_duration(arg: &str) -> Result { diff --git a/nym-node-status-api/src/main.rs b/nym-node-status-api/src/main.rs index 9c01bcf59f..b2c68b391b 100644 --- a/nym-node-status-api/src/main.rs +++ b/nym-node-status-api/src/main.rs @@ -26,11 +26,12 @@ async fn main() -> anyhow::Result<()> { args_clone.explorer_client_timeout, args_clone.nym_api_client_timeout, &args_clone.nyxd_addr, + args_clone.monitor_refresh_interval, ) .await; tracing::info!("Started monitor task"); }); - testruns::spawn(storage.pool_owned()).await; + testruns::spawn(storage.pool_owned(), args.testruns_refresh_interval).await; let shutdown_handles = http::server::start_http_api( storage.pool_owned(), diff --git a/nym-node-status-api/src/monitor/mod.rs b/nym-node-status-api/src/monitor/mod.rs index 3eb4129a8e..680a9ce312 100644 --- a/nym-node-status-api/src/monitor/mod.rs +++ b/nym-node-status-api/src/monitor/mod.rs @@ -22,7 +22,6 @@ use tokio::time::Duration; use tracing::instrument; // TODO dz should be configurable -const REFRESH_DELAY: Duration = Duration::from_secs(60 * 5); const FAILURE_RETRY_DELAY: Duration = Duration::from_secs(60); static DELEGATION_PROGRAM_WALLET: &str = "n1rnxpdpx3kldygsklfft0gech7fhfcux4zst5lw"; @@ -35,6 +34,7 @@ pub(crate) async fn spawn_in_background( explorer_client_timeout: Duration, nym_api_client_timeout: Duration, nyxd_addr: &Url, + refresh_interval: Duration, ) { let network_defaults = nym_network_defaults::NymNetworkDetails::new_from_env(); @@ -59,9 +59,9 @@ pub(crate) async fn spawn_in_background( } else { tracing::info!( "Info successfully collected, sleeping for {}s...", - REFRESH_DELAY.as_secs() + refresh_interval.as_secs() ); - tokio::time::sleep(REFRESH_DELAY).await; + tokio::time::sleep(refresh_interval).await; } } } diff --git a/nym-node-status-api/src/testruns/mod.rs b/nym-node-status-api/src/testruns/mod.rs index 02308d7b2a..86b36cf48e 100644 --- a/nym-node-status-api/src/testruns/mod.rs +++ b/nym-node-status-api/src/testruns/mod.rs @@ -8,10 +8,7 @@ pub(crate) mod models; mod queue; pub(crate) use queue::now_utc; -// TODO dz should be configurable -const REFRESH_DELAY: Duration = Duration::from_secs(60 * 5); - -pub(crate) async fn spawn(pool: DbPool) { +pub(crate) async fn spawn(pool: DbPool, refresh_interval: Duration) { tokio::spawn(async move { loop { tracing::info!("Spawning testruns..."); @@ -19,8 +16,8 @@ pub(crate) async fn spawn(pool: DbPool) { if let Err(e) = run(&pool).await { tracing::error!("Cron job failed: {}", e); } - tracing::debug!("Sleeping for {}s...", REFRESH_DELAY.as_secs()); - tokio::time::sleep(REFRESH_DELAY).await; + tracing::debug!("Sleeping for {}s...", refresh_interval.as_secs()); + tokio::time::sleep(refresh_interval).await; } }); } @@ -73,7 +70,7 @@ async fn run(pool: &DbPool) -> anyhow::Result<()> { testruns_created += 1; } } - tracing::debug!("Queued {} testruns", testruns_created); + tracing::debug!("{} testruns queued in total", testruns_created); Ok(()) }