// use actix_web::{rt::System, web, App, HttpResponse, HttpServer}; use std::sync::mpsc; use std::thread; #[actix_web::main] async fn main() { let (tx, rx) = mpsc::channel(); thread::spawn(move || { let sys = System::new("http-server"); let srv = HttpServer::new(|| { App::new().route("/", web::get().to(|| HttpResponse::Ok())) }) .bind("127.0.0.1:8080")? .shutdown_timeout(60) // <- Set shutdown timeout to 60 seconds .run(); let _ = tx.send(srv); sys.run() }); let srv = rx.recv().unwrap(); // pause accepting new connections srv.pause().await; // resume accepting new connections srv.resume().await; // stop server srv.stop(true).await; } //