mirror of
https://github.com/JakeHillion/scx.git
synced 2024-11-29 12:40:24 +00:00
scx_layered: Add --stats and make --monitor behavior consistent with scx_rusty
This commit is contained in:
parent
0f04a93dd1
commit
ae3024e938
@ -22,7 +22,6 @@ use std::ops::Sub;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
use std::thread::spawn;
|
||||
use std::thread::ThreadId;
|
||||
use std::time::Duration;
|
||||
use std::time::Instant;
|
||||
@ -240,7 +239,7 @@ lazy_static::lazy_static! {
|
||||
/// Monitoring Statistics
|
||||
/// =====================
|
||||
///
|
||||
/// Run with `--monitor INTERVAL` added to enable stats monitoring. There is
|
||||
/// Run with `--stats INTERVAL` added to enable stats monitoring. There is
|
||||
/// also scx_stat server listening on /var/run/scx/root/stat and you can
|
||||
/// monitor statistics by running `scx_layered --monitor INTERVAL`
|
||||
/// separately.
|
||||
@ -339,8 +338,12 @@ struct Opts {
|
||||
#[clap(short = 'e', long)]
|
||||
example: Option<String>,
|
||||
|
||||
/// Enable stats monitoring with the specified interval. If no layer
|
||||
/// specs are specified, run in monitor mode.
|
||||
/// Enable stats monitoring with the specified interval.
|
||||
#[clap(long)]
|
||||
stats: Option<f64>,
|
||||
|
||||
/// Run in stats monitoring mode with the specified interval. Scheduler
|
||||
/// is not launched.
|
||||
#[clap(long)]
|
||||
monitor: Option<f64>,
|
||||
|
||||
@ -1937,6 +1940,17 @@ fn main() -> Result<()> {
|
||||
})
|
||||
.context("Error setting Ctrl-C handler")?;
|
||||
|
||||
if let Some(intv) = opts.monitor.or(opts.stats) {
|
||||
let shutdown_copy = shutdown.clone();
|
||||
let jh = std::thread::spawn(move || {
|
||||
stats::monitor(Duration::from_secs_f64(intv), shutdown_copy).unwrap()
|
||||
});
|
||||
if opts.monitor.is_some() {
|
||||
let _ = jh.join();
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(path) = &opts.example {
|
||||
write_example_file(path)?;
|
||||
return Ok(());
|
||||
@ -1950,16 +1964,6 @@ fn main() -> Result<()> {
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(intv) = opts.monitor {
|
||||
let shutdown_copy = shutdown.clone();
|
||||
let jh =
|
||||
spawn(move || stats::monitor(Duration::from_secs_f64(intv), shutdown_copy).unwrap());
|
||||
if layer_config.specs.len() == 0 {
|
||||
let _ = jh.join();
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
debug!("specs={}", serde_json::to_string_pretty(&layer_config)?);
|
||||
verify_layer_specs(&layer_config.specs)?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user