1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 16:02:59 +01:00

add 0.5 sec deley before exit

This commit is contained in:
Nikolay Kim 2018-03-22 18:41:02 -07:00
parent 5a25fd95f5
commit 449709dd7e

View File

@ -630,15 +630,18 @@ impl<H: IntoHttpHandler> Handler<StopServer> for HttpServer<H>
};
for worker in &self.workers {
let tx2 = tx.clone();
let fut = worker.1.send(StopWorker{graceful: dur}).into_actor(self);
ActorFuture::then(fut, move |_, slf, _| {
worker.1.send(StopWorker{graceful: dur})
.into_actor(self)
.then(move |_, slf, ctx| {
slf.workers.pop();
if slf.workers.is_empty() {
let _ = tx2.send(());
// we need to stop system if server was spawned
if slf.exit {
ctx.run_later(Duration::from_millis(500), |_, _| {
Arbiter::system().do_send(actix::msgs::SystemExit(0))
});
}
}
actix::fut::ok(())
@ -651,7 +654,9 @@ impl<H: IntoHttpHandler> Handler<StopServer> for HttpServer<H>
} else {
// we need to stop system if server was spawned
if self.exit {
ctx.run_later(Duration::from_millis(500), |_, _| {
Arbiter::system().do_send(actix::msgs::SystemExit(0))
});
}
Response::reply(Ok(()))
}