File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ keywords = ["shuttle-service", "ntex"]
11
11
12
12
[dependencies ]
13
13
ntex = { version = " 1.2.1" , features = [" tokio" ] }
14
- ntex-rt = " 0.4.12 "
14
+ ntex-rt = " 0.4.13 "
15
15
tokio = { version = " 1.37.0" , features = [" rt-multi-thread" ] }
16
16
num_cpus = " 1.16.0"
17
17
shuttle-runtime = { path = " ../../runtime" , version = " 0.43.0" , default-features = false }
Original file line number Diff line number Diff line change 1
1
#![ doc = include_str ! ( "../README.md" ) ]
2
2
3
- use ntex:: Service ;
4
3
use std:: net:: SocketAddr ;
5
4
6
5
/// A wrapper type for a closure that returns an [ntex::web::ServiceConfig] so we can implement
@@ -15,17 +14,25 @@ where
15
14
{
16
15
async fn bind ( mut self , addr : SocketAddr ) -> Result < ( ) , shuttle_runtime:: Error > {
17
16
// 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 ( ) ;
19
18
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 ) ;
25
22
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 ( ) ;
27
28
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 > ( ( ) )
29
36
}
30
37
}
31
38
You can’t perform that action at this time.
0 commit comments