diff --git a/Cargo.toml b/Cargo.toml index ed24435f..058a15e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -207,14 +207,13 @@ default-features = false version = "4.5.21" default-features = false features = [ - "std", "derive", - "help", - #"color", Do we need these? - #"unicode", - "usage", + "env", "error-context", + "help", + "std", "string", + "usage", ] [workspace.dependencies.futures] diff --git a/src/main/clap.rs b/src/main/clap.rs index 638398dd..b10242be 100644 --- a/src/main/clap.rs +++ b/src/main/clap.rs @@ -5,7 +5,9 @@ use std::path::PathBuf; use clap::Parser; use conduit::{ config::{Figment, FigmentValue}, - err, toml, Err, Result, + err, toml, + utils::available_parallelism, + Err, Result, }; /// Commandline arguments @@ -32,6 +34,10 @@ pub(crate) struct Args { /// Set functional testing modes if available. Ex '--test=smoke' #[arg(long, hide(true))] pub(crate) test: Vec, + + /// Override the tokio worker_thread count. + #[arg(long, hide(true), env = "TOKIO_WORKER_THREADS", default_value = available_parallelism().to_string())] + pub(crate) worker_threads: usize, } /// Parse commandline arguments into structured data diff --git a/src/main/main.rs b/src/main/main.rs index 8e644a15..32d122f6 100644 --- a/src/main/main.rs +++ b/src/main/main.rs @@ -9,12 +9,11 @@ mod tracing; extern crate conduit_core as conduit; use std::{ - cmp, sync::{atomic::Ordering, Arc}, time::Duration, }; -use conduit::{debug_info, error, rustc_flags_capture, utils::available_parallelism, Error, Result}; +use conduit::{debug_info, error, rustc_flags_capture, Error, Result}; use server::Server; use tokio::runtime; @@ -30,7 +29,7 @@ fn main() -> Result<(), Error> { .enable_io() .enable_time() .thread_name(WORKER_NAME) - .worker_threads(cmp::max(WORKER_MIN, available_parallelism())) + .worker_threads(args.worker_threads.max(WORKER_MIN)) .thread_keep_alive(Duration::from_secs(WORKER_KEEPALIVE)) .build() .expect("built runtime");