better shutdown
This commit is contained in:
parent
6fefb35aca
commit
7723d1223a
|
@ -6,4 +6,3 @@ members = ["salut", "desec"]
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
strip = "symbols"
|
strip = "symbols"
|
||||||
panic = "abort"
|
|
||||||
|
|
|
@ -48,13 +48,24 @@ async fn main() -> Result<(), anyhow::Error> {
|
||||||
);
|
);
|
||||||
let cert_clone = certs.clone();
|
let cert_clone = certs.clone();
|
||||||
let host_clone = host.clone();
|
let host_clone = host.clone();
|
||||||
tokio::spawn(async move {
|
let tls_handle = tokio::spawn(async move {
|
||||||
server::listen_tls(host_clone, cfg.tls_port, cert_clone)
|
server::listen_tls(host_clone, cfg.tls_port, cert_clone)
|
||||||
.await
|
.await
|
||||||
.expect("TLS listener")
|
.expect("TLS listener")
|
||||||
});
|
});
|
||||||
server::listen_starttls(host, cfg.insecure_port, certs)
|
let starttls_handle = tokio::spawn(async move {
|
||||||
.await
|
server::listen_starttls(host, cfg.insecure_port, certs)
|
||||||
.expect("STARTTLS listener");
|
.await
|
||||||
Ok(())
|
.expect("STARTTLS listener");
|
||||||
|
});
|
||||||
|
tokio::select! {
|
||||||
|
_ = tls_handle => {
|
||||||
|
error!("tls handler returned unexpectedly");
|
||||||
|
},
|
||||||
|
_ = starttls_handle => {
|
||||||
|
error!("starttls handler returned unexpectedly");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Err(anyhow::anyhow!("unexpected server shutdown"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue