initial integration with telem viz
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
#![warn(clippy::all, clippy::pedantic)]
|
||||
use log::info;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
pub mod command;
|
||||
pub mod logger;
|
||||
pub mod on_drop;
|
||||
pub mod telemetry;
|
||||
pub mod udp;
|
||||
|
||||
@@ -12,10 +11,25 @@ pub mod udp;
|
||||
///
|
||||
/// # Errors
|
||||
/// If a system error occurred while trying to set the ctrl-c handler
|
||||
pub fn add_ctrlc_handler(flag: Arc<AtomicBool>) -> anyhow::Result<()> {
|
||||
pub fn add_ctrlc_handler_arc(
|
||||
flag: std::sync::Arc<std::sync::atomic::AtomicBool>,
|
||||
) -> anyhow::Result<()> {
|
||||
ctrlc::set_handler(move || {
|
||||
info!("Shutdown Requested");
|
||||
flag.store(false, Ordering::Relaxed);
|
||||
flag.store(false, std::sync::atomic::Ordering::Relaxed);
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Add a ctrl-c handler which will set an atomic flag to `false` when ctrl-c is detected
|
||||
///
|
||||
/// # Errors
|
||||
/// If a system error occurred while trying to set the ctrl-c handler
|
||||
#[cfg(feature = "async")]
|
||||
pub fn add_ctrlc_handler_cancel(cancel: tokio_util::sync::CancellationToken) -> anyhow::Result<()> {
|
||||
ctrlc::set_handler(move || {
|
||||
info!("Shutdown Requested");
|
||||
cancel.cancel();
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user