async fn wait_signal(tx_web: &mut Sender<()>, tx_watcher: mpsc::Sender<RawEvent>) -> Result<()> {
    let signals = Signals::new(&[signal_hook::SIGINT, signal_hook::SIGHUP])?;
    for signal in &signals {
        match signal {
            signal_hook::SIGINT | signal_hook::SIGHUP => {
                info!("Signal Received.");

                // wait on there being no in flight requests.
                wait_for_completion_of_in_flight_uploads(
                    Duration::from_secs(1),
                    Duration::from_secs(3),
                    Duration::from_secs(30),
                    &IN_FLIGHT_UPLOADS,
                )
                .await?;

                // shutdown the watcher
                tx_watcher.send(RawEvent {
                    path: None,
                    op: Err(notify::Error::Generic("Abort".to_string())),
                    cookie: None,
                })?;

                // shut down the web server
                let _ = tx_web.send(()).await;
                break;
            }
            _ => unreachable!(),
        }
    }
    Ok(())
}
// wait for a SIGINT or SIGHUP and then ensure everything shuts down gracefully.
wait for a SIGINT or SIGHUP and then ensure everything shuts down gracefully.
wait for a SIGINT or SIGHUP and then ensure everything shuts down gracefully .
async fn wait_signal(tx_web: &mut Sender<()>, tx_watcher: mpsc::Sender<RawEvent>) -> Result<()> {
    let signals = Signals::new(&[signal_hook::SIGINT, signal_hook::SIGHUP])?;
    for signal in &signals {
        match signal {
            signal_hook::SIGINT | signal_hook::SIGHUP => {
                info!("Signal Received.");
                // wait on there being no in flight requests.
                wait_for_completion_of_in_flight_uploads(
                    Duration::from_secs(1),
                    Duration::from_secs(3),
                    Duration::from_secs(30),
                    &IN_FLIGHT_UPLOADS,
                )
                .await?;
                // shutdown the watcher
                tx_watcher.send(RawEvent {
                    path: None,
                    op: Err(notify::Error::Generic("Abort".to_string())),
                    cookie: None,
                })?;
                // shut down the web server
                let _ = tx_web.send(()).await;
                break;
            }
            _ => unreachable!(),
        }
    }
    Ok(())
}
async fn wait_signal ( tx_web : & mut Sender < ( ) > , tx_watcher : mpsc :: Sender < RawEvent > ) -> Result < ( ) > { let signals = Signals :: new ( & [ signal_hook :: SIGINT , signal_hook :: SIGHUP ] ) ? ; for signal in & signals { match signal { signal_hook :: SIGINT | signal_hook :: SIGHUP => { info ! ( " " ) ; // wait on there being no in flight requests. wait_for_completion_of_in_flight_uploads ( Duration :: from_secs ( 1 ) , Duration :: from_secs ( 3 ) , Duration :: from_secs ( 30 ) , & IN_FLIGHT_UPLOADS , ) . await ? ; // shutdown the watcher tx_watcher . send ( RawEvent { path : None , op : Err ( notify :: Error :: Generic ( " " . to_string ( ) ) ) , cookie : None , } ) ? ; // shut down the web server let _ = tx_web . send ( ( ) ) . await ; break ; } _ => unreachable ! ( ) , } } Ok ( ( ) ) }
wait for a SIGINT or SIGHUP and then ensure everything shuts down gracefully.
wait for a SIGINT or SIGHUP and then ensure everything shuts down gracefully .
tx_web
&mut Sender<()>
tx_watcher
mpsc::Sender<RawEvent>
tx_web
&mut Sender<()>
tx_watcher
mpsc::Sender<RawEvent>