From cf794b63a7f6081009caf4fa8d43c2e6255d491a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Mon, 4 Dec 2023 15:35:42 +0000 Subject: [PATCH] review comments --- Cargo.lock | 1 - tools/nymvisor/Cargo.toml | 1 - tools/nymvisor/src/cli/mod.rs | 9 +++------ tools/nymvisor/src/cli/run.rs | 2 +- tools/nymvisor/src/error.rs | 3 +++ 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28a399412e..26ecc4a3b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7608,7 +7608,6 @@ dependencies = [ "hex", "humantime 2.1.0", "humantime-serde", - "lazy_static", "nix 0.27.1", "nym-bin-common", "nym-config", diff --git a/tools/nymvisor/Cargo.toml b/tools/nymvisor/Cargo.toml index 211f27f18d..47c2ab9101 100644 --- a/tools/nymvisor/Cargo.toml +++ b/tools/nymvisor/Cargo.toml @@ -20,7 +20,6 @@ futures = { workspace = true } hex = "0.4.3" humantime = "2.1.0" humantime-serde = "1.1.1" -lazy_static = { workspace = true } nix = { version = "0.27.1", features = ["signal", "fs"] } reqwest = { workspace = true, features = ["json", "stream"] } serde = { workspace = true, features = ["derive"] } diff --git a/tools/nymvisor/src/cli/mod.rs b/tools/nymvisor/src/cli/mod.rs index f530b39fa8..bb90d2d15b 100644 --- a/tools/nymvisor/src/cli/mod.rs +++ b/tools/nymvisor/src/cli/mod.rs @@ -5,10 +5,10 @@ use crate::config::{default_config_filepath, default_instances_directory, Config use crate::env::{setup_env, Env}; use crate::error::NymvisorError; use clap::{Parser, Subcommand}; -use lazy_static::lazy_static; use nym_bin_common::bin_info; use nym_config::{DEFAULT_CONFIG_DIR, DEFAULT_CONFIG_FILENAME}; use std::path::{Path, PathBuf}; +use std::sync::OnceLock; use tracing::{debug, error}; mod add_upgrade; @@ -19,13 +19,10 @@ pub(crate) mod helpers; mod init; mod run; -lazy_static! { - pub static ref PRETTY_BUILD_INFORMATION: String = bin_info!().pretty_print(); -} - // Helper for passing LONG_VERSION to clap fn pretty_build_info_static() -> &'static str { - &PRETTY_BUILD_INFORMATION + static PRETTY_BUILD_INFORMATION: OnceLock = OnceLock::new(); + PRETTY_BUILD_INFORMATION.get_or_init(|| bin_info!().pretty_print()) } #[derive(Parser, Debug)] diff --git a/tools/nymvisor/src/cli/run.rs b/tools/nymvisor/src/cli/run.rs index fc698f93e8..14ec534ff2 100644 --- a/tools/nymvisor/src/cli/run.rs +++ b/tools/nymvisor/src/cli/run.rs @@ -37,7 +37,7 @@ pub(crate) fn execute(args: Args) -> Result<(), NymvisorError> { let rt = runtime::Builder::new_current_thread() .enable_all() .build() - .expect("failed to create the runtime"); + .map_err(|source| NymvisorError::RuntimeCreationFailure { source })?; // we have three tasks only: // - one for managing the daemon launcher diff --git a/tools/nymvisor/src/error.rs b/tools/nymvisor/src/error.rs index 99c85598f4..9d12c78861 100644 --- a/tools/nymvisor/src/error.rs +++ b/tools/nymvisor/src/error.rs @@ -416,6 +416,9 @@ While the stored info point to:\n{stored_info:#?}" #[error("could not load the default config file as there isn't a single nymvisor instance initiated (there are {instances}). please specify either $NYMVISOR_CONFIG_PATH or $NYMVISOR_ID")] NotSingleton { instances: usize }, + + #[error("failed to crate tokio's runtime: {source}")] + RuntimeCreationFailure { source: io::Error }, } impl From for NymvisorError {