Skip to content

Commit 18aeb05

Browse files
committed
Update to ntex 0.4.13
1 parent 932d514 commit 18aeb05

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

services/shuttle-ntex/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ keywords = ["shuttle-service", "ntex"]
1111

1212
[dependencies]
1313
ntex = { version = "1.2.1", features = ["tokio"] }
14-
ntex-rt = "0.4.12"
14+
ntex-rt = "0.4.13"
1515
tokio = { version = "1.37.0", features = ["rt-multi-thread"] }
1616
num_cpus = "1.16.0"
1717
shuttle-runtime = { path = "../../runtime", version = "0.43.0", default-features = false }

services/shuttle-ntex/src/lib.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![doc = include_str!("../README.md")]
22

3-
use ntex::Service;
43
use std::net::SocketAddr;
54

65
/// A wrapper type for a closure that returns an [ntex::web::ServiceConfig] so we can implement
@@ -15,17 +14,25 @@ where
1514
{
1615
async fn bind(mut self, addr: SocketAddr) -> Result<(), shuttle_runtime::Error> {
1716
// Start a worker for each cpu, but no more than 4.
18-
let worker_count = num_cpus::get().min(4);
17+
let cloned_addr = addr.clone();
1918

20-
let server =
21-
ntex::web::HttpServer::new(move || ntex::web::App::new().configure(self.0.clone()))
22-
.workers(worker_count)
23-
.bind(addr)?
24-
.run();
19+
ntex::rt::System::new("main")
20+
.run_local(async move {
21+
let worker_count = num_cpus::get().min(4);
2522

26-
server.await.map_err(shuttle_runtime::CustomError::new)?;
23+
let server =
24+
ntex::web::HttpServer::new(move || ntex::web::App::new().configure(self.0.clone()))
25+
.workers(worker_count)
26+
.bind(cloned_addr)?
27+
.run();
2728

28-
Ok(())
29+
server.await.map_err(shuttle_runtime::CustomError::new)?;
30+
31+
Ok::<(), shuttle_runtime::Error>(())
32+
})
33+
.await?;
34+
35+
Ok::<(), shuttle_runtime::Error>(())
2936
}
3037
}
3138

0 commit comments

Comments
 (0)