mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 09:45:31 +00:00
udp: Config.socket_workers: make value 0 auto-use available vCPUs
This commit is contained in:
parent
f4ef9fcfc9
commit
14c973f72f
2 changed files with 9 additions and 3 deletions
|
|
@ -11,7 +11,9 @@ use aquatic_toml_config::TomlConfig;
|
|||
#[derive(Clone, Debug, PartialEq, TomlConfig, Deserialize, Serialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
pub struct Config {
|
||||
/// Number of socket workers. One per virtual CPU is recommended
|
||||
/// Number of socket workers
|
||||
///
|
||||
/// 0 = automatically set to number of available virtual CPUs
|
||||
pub socket_workers: usize,
|
||||
pub log_level: LogLevel,
|
||||
pub network: NetworkConfig,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ pub mod config;
|
|||
pub mod swarm;
|
||||
pub mod workers;
|
||||
|
||||
use std::thread::{sleep, Builder, JoinHandle};
|
||||
use std::thread::{available_parallelism, sleep, Builder, JoinHandle};
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::Context;
|
||||
|
|
@ -22,9 +22,13 @@ use workers::socket::ConnectionValidator;
|
|||
pub const APP_NAME: &str = "aquatic_udp: UDP BitTorrent tracker";
|
||||
pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
pub fn run(config: Config) -> ::anyhow::Result<()> {
|
||||
pub fn run(mut config: Config) -> ::anyhow::Result<()> {
|
||||
let mut signals = Signals::new([SIGUSR1])?;
|
||||
|
||||
if config.socket_workers == 0 {
|
||||
config.socket_workers = available_parallelism().map(Into::into).unwrap_or(1);
|
||||
};
|
||||
|
||||
let state = State::default();
|
||||
let statistics = Statistics::new(&config);
|
||||
let connection_validator = ConnectionValidator::new(&config)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue