pub async fn background_worker(&self, shutdown: tokio_util::sync::CancellationToken) {
        info!("started background worker");

        let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(1));

        while !shutdown.is_cancelled() {
            if self.require_id().is_ok() {
                if let Err(e) = self.maybe_initialize_server().await {
                    error!(%e, "error during DB loading");
                }
            }

            self.jobs.inner.lock().reclaim();

            tokio::select! {
                _ = interval.tick() => {},
                _ = shutdown.cancelled() => break
            }
        }

        info!("shutting down background workers");
        self.config.drain().await;

        info!("draining tracker registry");

        // Wait for any outstanding jobs to finish - frontend shutdown should be
        // sequenced before shutting down the background workers and so there
        // shouldn't be any
        while self.jobs.inner.lock().tracked_len() != 0 {
            self.jobs.inner.lock().reclaim();

            interval.tick().await;
        }

        info!("drained tracker registry");
    }
/// Background worker function for the server
Background worker function for the server
Background worker function for the server
pub async fn background_worker(&self, shutdown: tokio_util::sync::CancellationToken) {
        info!("started background worker");
        let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(1));
        while !shutdown.is_cancelled() {
            if self.require_id().is_ok() {
                if let Err(e) = self.maybe_initialize_server().await {
                    error!(%e, "error during DB loading");
                }
            }
            self.jobs.inner.lock().reclaim();
            tokio::select! {
                _ = interval.tick() => {},
                _ = shutdown.cancelled() => break
            }
        }
        info!("shutting down background workers");
        self.config.drain().await;
        info!("draining tracker registry");
        // Wait for any outstanding jobs to finish - frontend shutdown should be
        // sequenced before shutting down the background workers and so there
        // shouldn't be any
        while self.jobs.inner.lock().tracked_len() != 0 {
            self.jobs.inner.lock().reclaim();
            interval.tick().await;
        }
        info!("drained tracker registry");
    }
pub async fn background_worker ( & self , shutdown : tokio_util :: sync :: CancellationToken ) { info ! ( " " ) ; let mut interval = tokio :: time :: interval ( tokio :: time :: Duration :: from_secs ( 1 ) ) ; while ! shutdown . is_cancelled ( ) { if self . require_id ( ) . is_ok ( ) { if let Err ( e ) = self . maybe_initialize_server ( ) . await { error ! ( e " " ) ; } } self . jobs . inner . lock ( ) . reclaim ( ) ; tokio :: select ! { interval tick ( ) { } shutdown cancelled ( ) break } } info ! ( " " ) ; self . config . drain ( ) . await ; info ! ( " " ) ; // Wait for any outstanding jobs to finish - frontend shutdown should be // sequenced before shutting down the background workers and so there // shouldn't be any while self . jobs . inner . lock ( ) . tracked_len ( ) != 0 { self . jobs . inner . lock ( ) . reclaim ( ) ; interval . tick ( ) . await ; } info ! ( " " ) ; }
Background worker function for the server
Background worker function for the server
&self
shutdown
tokio_util::sync::CancellationToken
&self
shutdown
tokio_util::sync::CancellationToken