Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shutdown takes time #175

Open
ryardley opened this issue Nov 5, 2024 · 0 comments
Open

Shutdown takes time #175

ryardley opened this issue Nov 5, 2024 · 0 comments
Labels
Ciphernode Related to the ciphernode package enhancement New feature or request good first issue Good for newcomers

Comments

@ryardley
Copy link
Contributor

ryardley commented Nov 5, 2024

pub async fn listen_for_shutdown(bus: Recipient<EnclaveEvent>, handle: JoinHandle<()>) {
    let mut sigterm =
        signal(SignalKind::terminate()).expect("Failed to create SIGTERM signal stream");

    sigterm.recv().await;
    info!("SIGTERM received, initiating graceful shutdown...");

    // Stop the actor system
    let _ = bus.send(EnclaveEvent::from(Shutdown)).await;

    // Abort the spawned task
    handle.abort();

    // Wait for all actor processes to disconnect
    tokio::time::sleep(Duration::from_secs(2)).await;

    // Wait for the task to finish
    let _ = handle.await;

    info!("Graceful shutdown complete");
}

We are waiting 2 seconds then waiting for libbp2p to shutdown in sequence. We should shutdown more quickly

@ryardley ryardley added enhancement New feature or request Ciphernode Related to the ciphernode package good first issue Good for newcomers labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ciphernode Related to the ciphernode package enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant