diff --git a/Cargo.toml b/Cargo.toml index ebaa7833dd9b953fde5c9402eee74b45024d2039..45b80b678d1f262d26108cc556fed0cbd40886f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ handlebars = "3.4" regex = "1.3" tokio-stream = "0.1" clap = { version = "3.1", features = ["derive"]} -console-subscriber = "0.1.8" +console-subscriber = { version = "0.1.8", optional = true } [dependencies.collective] git = "https://gitlab.chromabits.com/etcinit/collective.git" @@ -50,7 +50,7 @@ rev = "f6f46f690d63f142ad6c5e95dd806d24b9cea6d4" [dependencies.tokio] version = "1.0" -features = ["signal", "macros", "fs", "sync", "tracing"] +features = ["signal", "macros", "fs", "sync"] [dependencies.tokio-util] version = "0.7" @@ -62,4 +62,7 @@ rev = "1bd30fbd1a219e8982571da48eb68f34317d1e15" [dependencies.async-compression] version = "0.3" -features = ["gzip", "tokio"] \ No newline at end of file +features = ["gzip", "tokio"] + +[features] +console-subscriber = ["dep:console-subscriber", "tokio/tracing"] \ No newline at end of file diff --git a/README.md b/README.md index de28913a456683cc8d2ef844f77c4bb3237077a4..24574e2941f3dfa0f3ba7f68a7b0fafc2a92d1b3 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,11 @@ minikube service --url espresso `RUST_LOG=info cargo run` to build and run the server. `RUST_LOG=info cargo test` to run all tests. + +**tokio-console:** + +Support for `tokio-console` can be enabled with the `console-subscriber` flag: + +```sh +RUSTFLAGS="--cfg tokio_unstable" cargo run -F console-subscriber +``` \ No newline at end of file diff --git a/src/cli/serve.rs b/src/cli/serve.rs index 0bd11814c761ffc54040dc329a122e78c36149d8..641dc5110f2c6fbc167128c53dbf863e86ddbf5d 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -35,8 +35,6 @@ 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. let (monitor_tx, monitor_rx) = mpsc::channel(); diff --git a/src/main.rs b/src/main.rs index bdcf935559e2730dac8dd427eb7aed3d9e122bf1..3ed7398c12834c203f25ba9da4abeee9c33ded9d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,9 @@ type Result<T, E = Error> = std::result::Result<T, E>; #[actix_rt::main] async fn main() -> Result<()> { + #[cfg(feature = "console-subscriber")] + console_subscriber::init(); + let result = inner_main().await; if let Err(Error::CliError {