mirror of
https://github.com/actix/examples
synced 2025-02-17 15:23:31 +01:00
Updated basics/shutdown-server to v4. (#481)
This commit is contained in:
parent
4d82158b0f
commit
a3a4786d00
@ -6,7 +6,7 @@ edition = "2018"
|
|||||||
description = "Send a request to the server to shut it down"
|
description = "Send a request to the server to shut it down"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "3"
|
actix-web = "4.0.0-beta.21"
|
||||||
env_logger = "0.8"
|
env_logger = "0.9"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
tokio = { version = "0.2", features = ["signal"] }
|
tokio = { version = "1.16", features = ["signal"] }
|
||||||
|
@ -29,7 +29,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
let server = HttpServer::new(move || {
|
let server = HttpServer::new(move || {
|
||||||
// give the server a Sender in .data
|
// give the server a Sender in .data
|
||||||
App::new()
|
App::new()
|
||||||
.data(tx.clone())
|
.app_data(web::Data::new(tx.clone()))
|
||||||
.wrap(middleware::Logger::default())
|
.wrap(middleware::Logger::default())
|
||||||
.service(hello)
|
.service(hello)
|
||||||
.service(stop)
|
.service(stop)
|
||||||
@ -38,7 +38,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.run();
|
.run();
|
||||||
|
|
||||||
// clone the Server handle
|
// clone the Server handle
|
||||||
let srv = server.clone();
|
let srv = server.handle();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
// wait for shutdown signal
|
// wait for shutdown signal
|
||||||
rx.recv().unwrap();
|
rx.recv().unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user