mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-23 20:51:06 +01:00
Fix worker are notified to stop with non_graceful shutdown (#333)
This commit is contained in:
parent
47fba25d67
commit
aeb81ad3fd
@ -1,6 +1,10 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
* Server shutdown would notify all workers to exit regardless if shutdown is graceful.
|
||||
This would make all worker shutdown immediately in force shutdown case. [#333]
|
||||
|
||||
[#333]: https://github.com/actix/actix-net/pull/333
|
||||
|
||||
|
||||
## 2.0.0-beta.4 - 2021-04-01
|
||||
|
@ -381,45 +381,29 @@ impl ServerBuilder {
|
||||
let notify = std::mem::take(&mut self.notify);
|
||||
|
||||
// stop workers
|
||||
if !self.handles.is_empty() && graceful {
|
||||
let iter = self
|
||||
.handles
|
||||
.iter()
|
||||
.map(move |worker| worker.1.stop(graceful))
|
||||
.collect();
|
||||
let stop = self
|
||||
.handles
|
||||
.iter()
|
||||
.map(move |worker| worker.1.stop(graceful))
|
||||
.collect();
|
||||
|
||||
let fut = join_all(iter);
|
||||
|
||||
rt::spawn(async move {
|
||||
let _ = fut.await;
|
||||
if let Some(tx) = completion {
|
||||
let _ = tx.send(());
|
||||
}
|
||||
for tx in notify {
|
||||
let _ = tx.send(());
|
||||
}
|
||||
if exit {
|
||||
rt::spawn(async {
|
||||
sleep(Duration::from_millis(300)).await;
|
||||
System::current().stop();
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// we need to stop system if server was spawned
|
||||
if self.exit {
|
||||
rt::spawn(async {
|
||||
sleep(Duration::from_millis(300)).await;
|
||||
System::current().stop();
|
||||
});
|
||||
rt::spawn(async move {
|
||||
if graceful {
|
||||
let _ = join_all(stop).await;
|
||||
}
|
||||
|
||||
if let Some(tx) = completion {
|
||||
let _ = tx.send(());
|
||||
}
|
||||
for tx in notify {
|
||||
let _ = tx.send(());
|
||||
}
|
||||
}
|
||||
|
||||
if exit {
|
||||
sleep(Duration::from_millis(300)).await;
|
||||
System::current().stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
ServerCommand::WorkerFaulted(idx) => {
|
||||
let mut found = false;
|
||||
|
Loading…
Reference in New Issue
Block a user