mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 20:12:58 +01:00
fix init order
This commit is contained in:
parent
b7b76c47e5
commit
1146d9cf30
@ -114,19 +114,23 @@ impl InternalServiceFactory for ConfiguredService {
|
|||||||
self.rt.configure(&mut rt);
|
self.rt.configure(&mut rt);
|
||||||
rt.validate();
|
rt.validate();
|
||||||
|
|
||||||
|
let services = rt.services;
|
||||||
|
|
||||||
|
// on start futures
|
||||||
|
if rt.onstart.is_empty() {
|
||||||
// construct services
|
// construct services
|
||||||
let mut fut = Vec::new();
|
let mut fut = Vec::new();
|
||||||
for (token, ns) in rt.services {
|
for (token, ns) in services {
|
||||||
let config = ServerConfig::new(self.names[&token].1);
|
let config = ServerConfig::new(self.names[&token].1);
|
||||||
fut.push(ns.new_service(&config).map(move |service| (token, service)));
|
fut.push(ns.new_service(&config).map(move |service| (token, service)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// on start futures
|
|
||||||
if rt.onstart.is_empty() {
|
|
||||||
Box::new(join_all(fut).map_err(|e| {
|
Box::new(join_all(fut).map_err(|e| {
|
||||||
error!("Can not construct service: {:?}", e);
|
error!("Can not construct service: {:?}", e);
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
|
let names = self.names.clone();
|
||||||
|
|
||||||
// run onstart future and then construct services
|
// run onstart future and then construct services
|
||||||
Box::new(
|
Box::new(
|
||||||
join_all(rt.onstart)
|
join_all(rt.onstart)
|
||||||
@ -134,6 +138,14 @@ impl InternalServiceFactory for ConfiguredService {
|
|||||||
error!("Can not construct service: {:?}", e);
|
error!("Can not construct service: {:?}", e);
|
||||||
})
|
})
|
||||||
.and_then(move |_| {
|
.and_then(move |_| {
|
||||||
|
// construct services
|
||||||
|
let mut fut = Vec::new();
|
||||||
|
for (token, ns) in services {
|
||||||
|
let config = ServerConfig::new(names[&token].1);
|
||||||
|
fut.push(
|
||||||
|
ns.new_service(&config).map(move |service| (token, service)),
|
||||||
|
);
|
||||||
|
}
|
||||||
join_all(fut).map_err(|e| {
|
join_all(fut).map_err(|e| {
|
||||||
error!("Can not construct service: {:?}", e);
|
error!("Can not construct service: {:?}", e);
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user