better shutdown

This commit is contained in:
emilis 2023-07-01 12:08:24 +01:00
parent 6fefb35aca
commit 7723d1223a
2 changed files with 16 additions and 6 deletions

View File

@ -6,4 +6,3 @@ members = ["salut", "desec"]
lto = "fat"
opt-level = 3
strip = "symbols"
panic = "abort"

View File

@ -48,13 +48,24 @@ async fn main() -> Result<(), anyhow::Error> {
);
let cert_clone = certs.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)
.await
.expect("TLS listener")
});
let starttls_handle = tokio::spawn(async move {
server::listen_starttls(host, cfg.insecure_port, certs)
.await
.expect("STARTTLS listener");
Ok(())
});
tokio::select! {
_ = tls_handle => {
error!("tls handler returned unexpectedly");
},
_ = starttls_handle => {
error!("starttls handler returned unexpectedly");
},
};
Err(anyhow::anyhow!("unexpected server shutdown"))
}