darpi-rs / darpi

A rust web framework with safety and speed in mind.
https://darpi-rs.github.io/book/
33 stars 1 forks source link

add graceful shutdown opt #12

Closed petar-dambovaliev closed 3 years ago

stappersg commented 3 years ago

What will it bring? Remote shutdown expliot?

Do know that it is OK to leave those unanswered.. That focus on the actual code is more important. And explain in the upcoming commit message on the why.

petar-dambovaliev commented 3 years ago

What will it bring? Remote shutdown expliot?

Do know that it is OK to leave those unanswered.. That focus on the actual code is more important. And explain in the upcoming commit message on the why.

No, this is actually to add a way for you to shutdown the server.

let mut app = app!({
        address: "127.0.0.1:3000",
        handlers: [{
            route: "/",
            method: GET,
            handler: my_handler
        }]
    });

    let shutdown = app.shutdown_signal().unwrap();
    shutdown.send(()).unwrap();