Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function main returns exit status #1126

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@
BeginNewMain(UpgradeError),
#[error("{0}")]
Cli(CtlError),
#[error("paw io error: {0}")]
Io(std::io::Error),
}

impl From<std::io::Error> for MainError {
fn from(value: std::io::Error) -> Self {
Self::Io(value)
}
}

#[paw::main]
fn main(args: Args) {
fn main(args: Args) -> Result<(), MainError> {
register_panic_hook();

let result = match args.cmd {
Expand Down Expand Up @@ -119,10 +127,11 @@
}
_ => ctl::ctl(args).map_err(MainError::Cli),
};
match result {
Ok(_) => {}
Err(main_error) => println!("{}", main_error),

if let Err(main_error) = &result {
eprintln!("\n{main_error}\n");
}
result
}

/// Set workers process affinity, see man sched_setaffinity
Expand All @@ -130,7 +139,7 @@
/// Can bind multiple processes to a CPU core if there are more processes
/// than CPU cores. Only works on Linux.
#[cfg(target_os = "linux")]
fn set_workers_affinity(workers: &Vec<WorkerSession>) {

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Build Sozu 🦀

function `set_workers_affinity` is never used

Check warning on line 142 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Build Sozu 🦀

function `set_workers_affinity` is never used
let mut cpu_count = 0;
let max_cpu = num_cpus::get();

Expand Down Expand Up @@ -169,7 +178,7 @@
#[cfg(target_os = "linux")]
use std::mem;
#[cfg(target_os = "linux")]
fn set_process_affinity(pid: pid_t, cpu: usize) {

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, true)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, stable)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Test (false, beta)

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Build Sozu 🦀

function `set_process_affinity` is never used

Check warning on line 181 in bin/src/main.rs

View workflow job for this annotation

GitHub Actions / Build Sozu 🦀

function `set_process_affinity` is never used
unsafe {
let mut cpu_set: cpu_set_t = mem::zeroed();
let size_cpu_set = mem::size_of::<cpu_set_t>();
Expand Down
Loading