passthru worker thread count from env

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-11-23 03:45:11 +00:00
parent 175e1c6453
commit 5f1cab6850
3 changed files with 13 additions and 9 deletions

View file

@ -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]

View file

@ -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<String>,
/// 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

View file

@ -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");