mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-24 01:11:07 +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
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## 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
|
## 2.0.0-beta.4 - 2021-04-01
|
||||||
|
@ -381,45 +381,29 @@ impl ServerBuilder {
|
|||||||
let notify = std::mem::take(&mut self.notify);
|
let notify = std::mem::take(&mut self.notify);
|
||||||
|
|
||||||
// stop workers
|
// stop workers
|
||||||
if !self.handles.is_empty() && graceful {
|
let stop = self
|
||||||
let iter = self
|
|
||||||
.handles
|
.handles
|
||||||
.iter()
|
.iter()
|
||||||
.map(move |worker| worker.1.stop(graceful))
|
.map(move |worker| worker.1.stop(graceful))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let fut = join_all(iter);
|
|
||||||
|
|
||||||
rt::spawn(async move {
|
rt::spawn(async move {
|
||||||
let _ = fut.await;
|
if graceful {
|
||||||
|
let _ = join_all(stop).await;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(tx) = completion {
|
if let Some(tx) = completion {
|
||||||
let _ = tx.send(());
|
let _ = tx.send(());
|
||||||
}
|
}
|
||||||
for tx in notify {
|
for tx in notify {
|
||||||
let _ = tx.send(());
|
let _ = tx.send(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if exit {
|
if exit {
|
||||||
rt::spawn(async {
|
|
||||||
sleep(Duration::from_millis(300)).await;
|
sleep(Duration::from_millis(300)).await;
|
||||||
System::current().stop();
|
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();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if let Some(tx) = completion {
|
|
||||||
let _ = tx.send(());
|
|
||||||
}
|
|
||||||
for tx in notify {
|
|
||||||
let _ = tx.send(());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ServerCommand::WorkerFaulted(idx) => {
|
ServerCommand::WorkerFaulted(idx) => {
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user