Skip to content

Commit

Permalink
Better interrupt message (#1874)
Browse files Browse the repository at this point in the history
Co-authored-by: raphjaph <raphjaph@protonmail.com>
  • Loading branch information
neunenak and raphjaph authored Mar 7, 2023
1 parent 332a0bd commit 8b7886d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ fn timestamp(seconds: u32) -> DateTime<Utc> {
Utc.timestamp_opt(seconds.into(), 0).unwrap()
}

const INTERRUPT_LIMIT: u64 = 5;

pub fn main() {
env_logger::init();

Expand All @@ -151,9 +153,11 @@ pub fn main() {
.iter()
.for_each(|handle| handle.graceful_shutdown(Some(Duration::from_millis(100))));

println!("Detected Ctrl-C, attempting to shut down ord gracefully. Press Ctrl-C {INTERRUPT_LIMIT} times to force shutdown.");

let interrupts = INTERRUPTS.fetch_add(1, atomic::Ordering::Relaxed);

if interrupts > 5 {
if interrupts > INTERRUPT_LIMIT {
process::exit(1);
}
})
Expand Down

0 comments on commit 8b7886d

Please sign in to comment.