1
0
mirror of https://github.com/actix/actix-website synced 2025-02-02 12:19:04 +01:00

33 lines
902 B
Rust
Raw Normal View History

2018-05-23 20:39:15 -07:00
// <signals>
2019-12-29 03:32:56 +09:00
use actix_rt::System;
2019-06-13 17:10:51 -04:00
use actix_web::{web, App, HttpResponse, HttpServer};
2018-05-23 20:39:15 -07:00
use std::sync::mpsc;
use std::thread;
2019-06-13 17:10:51 -04:00
pub fn main() {
2018-05-23 20:39:15 -07:00
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
2019-12-29 03:32:56 +09:00
let sys = System::new("http-server");
2019-06-13 17:10:51 -04:00
let addr = HttpServer::new(|| {
App::new().route("/", web::get().to(|| HttpResponse::Ok()))
2018-05-23 20:39:15 -07:00
})
2019-06-13 17:10:51 -04:00
.bind("127.0.0.1:8088")
.unwrap()
.shutdown_timeout(60) // <- Set shutdown timeout to 60 seconds
2019-12-29 03:32:56 +09:00
.run();
2019-06-13 17:10:51 -04:00
2018-05-23 20:39:15 -07:00
let _ = tx.send(addr);
});
let addr = rx.recv().unwrap();
2019-12-29 03:32:56 +09:00
let _ = System::new("`actix_server::ServerCommand::Pause`")
.block_on(addr.pause());
let _ = System::new("`actix_server::ServerCommand::Resume`")
.block_on(addr.resume());
let _ = System::new("`actix_server::ServerCommand::Stop`")
.block_on(addr.stop(true));
2018-05-23 20:39:15 -07:00
}
// </signals>