pub fn stop(&mut self) {
        use nix::sys::signal::{kill, Signal::SIGTERM};
        use nix::unistd::Pid;
        kill(Pid::from_raw(self.process.id() as i32), SIGTERM).ok();

        let mut tries_left = 300i32;
        let backoff = std::time::Duration::from_millis(100);
        while tries_left > 0 {
            tries_left -= 1;
            match self.process.try_wait() {
                Ok(Some(status)) => {
                    if self.can_panic {
                        assert!(
                            status.success(),
                            "ic-rosetta-api did not finish successfully. Exit status: {}",
                            status,
                        );
                    }
                    break;
                }
                Ok(None) => std::thread::sleep(backoff),
                Err(_) => {
                    if self.can_panic {
                        panic!("wait for rosetta-api finish: rosetta-api did not start(?)")
                    } else {
                        break;
                    }
                }
            }
        }
        if tries_left == 0 {
            self.process.kill().ok();
            if self.can_panic {
                panic!(
                    "rosetta-api did not finish in {} sec",
                    (backoff * 300).as_secs_f32()
                );
            }
        }
    }
// safe to call this multiple times
safe to call this multiple times
safe to call this multiple times
pub fn stop(&mut self) {
        use nix::sys::signal::{kill, Signal::SIGTERM};
        use nix::unistd::Pid;
        kill(Pid::from_raw(self.process.id() as i32), SIGTERM).ok();
        let mut tries_left = 300i32;
        let backoff = std::time::Duration::from_millis(100);
        while tries_left > 0 {
            tries_left -= 1;
            match self.process.try_wait() {
                Ok(Some(status)) => {
                    if self.can_panic {
                        assert!(
                            status.success(),
                            "ic-rosetta-api did not finish successfully. Exit status: {}",
                            status,
                        );
                    }
                    break;
                }
                Ok(None) => std::thread::sleep(backoff),
                Err(_) => {
                    if self.can_panic {
                        panic!("wait for rosetta-api finish: rosetta-api did not start(?)")
                    } else {
                        break;
                    }
                }
            }
        }
        if tries_left == 0 {
            self.process.kill().ok();
            if self.can_panic {
                panic!(
                    "rosetta-api did not finish in {} sec",
                    (backoff * 300).as_secs_f32()
                );
            }
        }
    }
pub fn stop ( & mut self ) { use nix :: sys :: signal :: { kill , Signal :: SIGTERM } ; use nix :: unistd :: Pid ; kill ( Pid :: from_raw ( self . process . id ( ) as i32 ) , SIGTERM ) . ok ( ) ; let mut tries_left = 300i32 ; let backoff = std :: time :: Duration :: from_millis ( 100 ) ; while tries_left > 0 { tries_left -= 1 ; match self . process . try_wait ( ) { Ok ( Some ( status ) ) => { if self . can_panic { assert ! ( status success ( ) " " status ) ; } break ; } Ok ( None ) => std :: thread :: sleep ( backoff ) , Err ( _ ) => { if self . can_panic { panic ! ( " " ) } else { break ; } } } } if tries_left == 0 { self . process . kill ( ) . ok ( ) ; if self . can_panic { panic ! ( " " ( backoff 300 ) as_secs_f32 ( ) ) ; } } }
safe to call this multiple times
safe to call this multiple times
&mut self
&mut self