passthru worker thread count from env
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
175e1c6453
commit
5f1cab6850
3 changed files with 13 additions and 9 deletions
|
@ -207,14 +207,13 @@ default-features = false
|
||||||
version = "4.5.21"
|
version = "4.5.21"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"std",
|
|
||||||
"derive",
|
"derive",
|
||||||
"help",
|
"env",
|
||||||
#"color", Do we need these?
|
|
||||||
#"unicode",
|
|
||||||
"usage",
|
|
||||||
"error-context",
|
"error-context",
|
||||||
|
"help",
|
||||||
|
"std",
|
||||||
"string",
|
"string",
|
||||||
|
"usage",
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.dependencies.futures]
|
[workspace.dependencies.futures]
|
||||||
|
|
|
@ -5,7 +5,9 @@ use std::path::PathBuf;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use conduit::{
|
use conduit::{
|
||||||
config::{Figment, FigmentValue},
|
config::{Figment, FigmentValue},
|
||||||
err, toml, Err, Result,
|
err, toml,
|
||||||
|
utils::available_parallelism,
|
||||||
|
Err, Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Commandline arguments
|
/// Commandline arguments
|
||||||
|
@ -32,6 +34,10 @@ pub(crate) struct Args {
|
||||||
/// Set functional testing modes if available. Ex '--test=smoke'
|
/// Set functional testing modes if available. Ex '--test=smoke'
|
||||||
#[arg(long, hide(true))]
|
#[arg(long, hide(true))]
|
||||||
pub(crate) test: Vec<String>,
|
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
|
/// Parse commandline arguments into structured data
|
||||||
|
|
|
@ -9,12 +9,11 @@ mod tracing;
|
||||||
extern crate conduit_core as conduit;
|
extern crate conduit_core as conduit;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
cmp,
|
|
||||||
sync::{atomic::Ordering, Arc},
|
sync::{atomic::Ordering, Arc},
|
||||||
time::Duration,
|
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 server::Server;
|
||||||
use tokio::runtime;
|
use tokio::runtime;
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ fn main() -> Result<(), Error> {
|
||||||
.enable_io()
|
.enable_io()
|
||||||
.enable_time()
|
.enable_time()
|
||||||
.thread_name(WORKER_NAME)
|
.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))
|
.thread_keep_alive(Duration::from_secs(WORKER_KEEPALIVE))
|
||||||
.build()
|
.build()
|
||||||
.expect("built runtime");
|
.expect("built runtime");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue