fn should_force_kill(
    service_handler: &ServiceHandler,
    shutting_down: impl Into<Option<ShuttingDown>>,
) -> bool {
    if service_handler.pid.is_none() {
        // Since it was in the started state, it doesn't have a pid yet.
        // Let's give it the time to start and exit.
        return false;
    }
    if let Some(ShuttingDown::Forcefuly) = shutting_down.into() {
        debug!("{}, should force kill.", service_handler.name());
        return true;
    }
    if let Some(shutting_down_elapsed_secs) = service_handler.shutting_down_start {
        let shutting_down_elapsed_secs = shutting_down_elapsed_secs.elapsed().as_secs();
        debug!(
            "{}, should not force kill. Elapsed: {}, termination wait: {}",
            service_handler.name(),
            shutting_down_elapsed_secs,
            service_handler.service().termination.wait.clone().as_secs()
        );
        shutting_down_elapsed_secs > service_handler.service().termination.wait.clone().as_secs()
    } else {
        // this might happen, because InKilling state is emitted before the Kill event.
        // So maybe the supervisor has received only the InKilling state change, but hasn't sent the
        // signal yet. So it should be fine.
        debug!("There is no shutting down elapsed secs.");
        false
    }
}
/// Check if we've waitied enough for the service to exit
Check if we've waitied enough for the service to exit
Check if we ' ve waitied enough for the service to exit
fn should_force_kill(
    service_handler: &ServiceHandler,
    shutting_down: impl Into<Option<ShuttingDown>>,
) -> bool {
    if service_handler.pid.is_none() {
        // Since it was in the started state, it doesn't have a pid yet.
        // Let's give it the time to start and exit.
        return false;
    }
    if let Some(ShuttingDown::Forcefuly) = shutting_down.into() {
        debug!("{}, should force kill.", service_handler.name());
        return true;
    }
    if let Some(shutting_down_elapsed_secs) = service_handler.shutting_down_start {
        let shutting_down_elapsed_secs = shutting_down_elapsed_secs.elapsed().as_secs();
        debug!(
            "{}, should not force kill. Elapsed: {}, termination wait: {}",
            service_handler.name(),
            shutting_down_elapsed_secs,
            service_handler.service().termination.wait.clone().as_secs()
        );
        shutting_down_elapsed_secs > service_handler.service().termination.wait.clone().as_secs()
    } else {
        // this might happen, because InKilling state is emitted before the Kill event.
        // So maybe the supervisor has received only the InKilling state change, but hasn't sent the
        // signal yet. So it should be fine.
        debug!("There is no shutting down elapsed secs.");
        false
    }
}
fn should_force_kill ( service_handler : & ServiceHandler , shutting_down : impl Into < Option < ShuttingDown > > , ) -> bool { if service_handler . pid . is_none ( ) { // Since it was in the started state, it doesn't have a pid yet. // Let's give it the time to start and exit. return false ; } if let Some ( ShuttingDown :: Forcefuly ) = shutting_down . into ( ) { debug ! ( " " service_handler name ( ) ) ; return true ; } if let Some ( shutting_down_elapsed_secs ) = service_handler . shutting_down_start { let shutting_down_elapsed_secs = shutting_down_elapsed_secs . elapsed ( ) . as_secs ( ) ; debug ! ( " " service_handler name ( ) shutting_down_elapsed_secs service_handler service ( ) termination wait clone ( ) as_secs ( ) ) ; shutting_down_elapsed_secs > service_handler . service ( ) . termination . wait . clone ( ) . as_secs ( ) } else { // this might happen, because InKilling state is emitted before the Kill event. // So maybe the supervisor has received only the InKilling state change, but hasn't sent the // signal yet. So it should be fine. debug ! ( " " ) ; false } }
Check if we've waitied enough for the service to exit
Check if we ' ve waitied enough for the service to exit
service_handler
&ServiceHandler
shutting_down
impl Into<Option<ShuttingDown>>
service_handler
&ServiceHandler
shutting_down
impl Into<Option<ShuttingDown>>