File tree Expand file tree Collapse file tree 2 files changed +20
-32
lines changed Expand file tree Collapse file tree 2 files changed +20
-32
lines changed Original file line number Diff line number Diff line change 1
1
# Changes
2
2
3
3
## Unreleased - 2021-xx-xx
4
+ * Server shutdown would notify all workers to exit regardless if shutdown is graceful.
5
+ This would make all worker shutdown immediately in force shutdown case. [ #333 ]
6
+
7
+ [ #333 ] : https://github.com/actix/actix-net/pull/333
4
8
5
9
6
10
## 2.0.0-beta.4 - 2021-04-01
Original file line number Diff line number Diff line change @@ -381,45 +381,29 @@ impl ServerBuilder {
381
381
let notify = std:: mem:: take ( & mut self . notify ) ;
382
382
383
383
// stop workers
384
- if !self . handles . is_empty ( ) && graceful {
385
- let iter = self
386
- . handles
387
- . iter ( )
388
- . map ( move |worker| worker. 1 . stop ( graceful) )
389
- . collect ( ) ;
390
-
391
- let fut = join_all ( iter) ;
392
-
393
- rt:: spawn ( async move {
394
- let _ = fut. await ;
395
- if let Some ( tx) = completion {
396
- let _ = tx. send ( ( ) ) ;
397
- }
398
- for tx in notify {
399
- let _ = tx. send ( ( ) ) ;
400
- }
401
- if exit {
402
- rt:: spawn ( async {
403
- sleep ( Duration :: from_millis ( 300 ) ) . await ;
404
- System :: current ( ) . stop ( ) ;
405
- } ) ;
406
- }
407
- } ) ;
408
- } else {
409
- // we need to stop system if server was spawned
410
- if self . exit {
411
- rt:: spawn ( async {
412
- sleep ( Duration :: from_millis ( 300 ) ) . await ;
413
- System :: current ( ) . stop ( ) ;
414
- } ) ;
384
+ let stop = self
385
+ . handles
386
+ . iter ( )
387
+ . map ( move |worker| worker. 1 . stop ( graceful) )
388
+ . collect ( ) ;
389
+
390
+ rt:: spawn ( async move {
391
+ if graceful {
392
+ let _ = join_all ( stop) . await ;
415
393
}
394
+
416
395
if let Some ( tx) = completion {
417
396
let _ = tx. send ( ( ) ) ;
418
397
}
419
398
for tx in notify {
420
399
let _ = tx. send ( ( ) ) ;
421
400
}
422
- }
401
+
402
+ if exit {
403
+ sleep ( Duration :: from_millis ( 300 ) ) . await ;
404
+ System :: current ( ) . stop ( ) ;
405
+ }
406
+ } ) ;
423
407
}
424
408
ServerCommand :: WorkerFaulted ( idx) => {
425
409
let mut found = false ;
You can’t perform that action at this time.
0 commit comments