From 84395a0ad882958fd88ef9335c7cde5bb3916835 Mon Sep 17 00:00:00 2001 From: Eduardo Trujillo <ed@chromabits.com> Date: Tue, 15 Nov 2022 13:18:11 -0800 Subject: [PATCH] fix(cli): Move thread monitor initialization to cli module --- src/cli/serve.rs | 2 ++ src/main.rs | 9 +-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/cli/serve.rs b/src/cli/serve.rs index 50911db..448b643 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -33,6 +33,8 @@ pub enum Error { type Result<T, E = Error> = std::result::Result<T, E>; pub async fn serve(config: Arc<Config>) -> Result<()> { + MONITOR.init().context(MonitorError)?; + console_subscriber::init(); // Set up a channel for receiving thread notifications. diff --git a/src/main.rs b/src/main.rs index b430f5a..9badbb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,19 +12,14 @@ use cli::{ }; use collective::{ cli::ConfigurableAppOpts, - thread::monitor::{self, ThreadMonitor}, + thread::monitor::{self}, }; use espresso::{bundle::packager, config, stats}; -use lazy_static::lazy_static; use snafu::{ResultExt, Snafu}; use std::{net::SocketAddr, sync::Arc}; pub mod cli; -lazy_static! { - static ref MONITOR: ThreadMonitor = ThreadMonitor::new(); -} - #[derive(Snafu, Debug)] pub enum Error { OpenConfig { @@ -69,8 +64,6 @@ async fn main() -> Result<()> { } async fn inner_main() -> Result<()> { - MONITOR.init().context(MonitorError)?; - let (opts, config) = Opts::try_init_with_config().context(CliError)?; let config = Arc::new(config); -- GitLab