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:
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user