diff --git a/packages/centipede/src/main.rs b/packages/centipede/src/main.rs index e1dc401..e7d74fc 100644 --- a/packages/centipede/src/main.rs +++ b/packages/centipede/src/main.rs @@ -22,6 +22,11 @@ mod config; struct Opt { /// Path to config file. config: PathBuf, + + /// Number of workers to spawn. + /// Defaults to the number of CPUs. + #[clap(long, short, default_value_t = num_cpus::get())] + workers: usize, } fn main() -> Result<()> { @@ -68,7 +73,7 @@ fn main() -> Result<()> { .with_name(config.interface_name) .with_address(config.address.address()) .with_netmask(config.address.network()) - .with_num_queues(config.workers) + .with_num_queues(opt.workers) .build() .into_diagnostic() .wrap_err("failed to create tun device")?; @@ -150,7 +155,7 @@ fn main() -> Result<()> { }); } - for i in 1..config.workers { + for i in 1..opt.workers { let shutdown = shutdown.clone(); let mut worker = Worker::new( router.worker(), diff --git a/peer1.toml b/peer1.toml index bee4351..321bae7 100644 --- a/peer1.toml +++ b/peer1.toml @@ -2,7 +2,6 @@ address = "10.0.10.1/24" private_key = "hteZOax4E+ELo6q5eSVoFAhh9awJudkYhzUJDvguNU0=" recv_addrs = ["10.0.1.1:5000"] interface_name = "cp1" -workers = 1 [[peers]] public_key = "Wx0KV+g6TkuSIbUF/FUEztkchnRw7akTxJ8JV8QcJi0=" diff --git a/peer2.toml b/peer2.toml index 406e02e..dbe276a 100644 --- a/peer2.toml +++ b/peer2.toml @@ -2,7 +2,6 @@ address = "10.0.10.2/24" private_key = "QJVxWbA6o/3kk5znUyD5rySYe+yG829uGNoh2PNVyxk=" recv_addrs = ["10.0.1.2:5000"] interface_name = "cp1" -workers = 1 [[peers]] public_key = "Gb1SnzVaODF8LHKoBD+dJtS/e/9GYEhnLX0sOk8OIbA="