1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

removed control-C handling because actix-server natively supports it

This commit is contained in:
dowwie
2020-02-12 07:53:01 -05:00
parent 120182f7de
commit c4c4b3e77b
4 changed files with 2 additions and 22 deletions

View File

@ -6,6 +6,7 @@ Demonstrates how to shutdown the web server in a couple of ways:
- Created in response to actix/actix-web#1315
2. sending a SIGINT signal to the server (control-c)
- actix-server natively supports SIGINT
## Usage

View File

@ -1,7 +1,7 @@
use actix_web::{get, middleware, post, web, App, HttpResponse, HttpServer};
use futures::executor;
use std::{sync::mpsc, thread};
use tokio::signal::unix::{signal, SignalKind};
#[get("/hello")]
async fn hello() -> &'static str {
@ -51,15 +51,6 @@ async fn main() -> std::io::Result<()> {
executor::block_on(srv.stop(true))
});
let mut stream = signal(SignalKind::interrupt())?;
actix_rt::spawn(async move {
loop {
stream.recv().await;
println!("\n*** SIGINT received. Stopping server, gracefully. ***\n");
stopper.send(()).unwrap();
}
});
// run server
server.await
}