better shutdown
This commit is contained in:
parent
6fefb35aca
commit
7723d1223a
|
@ -6,4 +6,3 @@ members = ["salut", "desec"]
|
|||
lto = "fat"
|
||||
opt-level = 3
|
||||
strip = "symbols"
|
||||
panic = "abort"
|
||||
|
|
|
@ -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")
|
||||
});
|
||||
server::listen_starttls(host, cfg.insecure_port, certs)
|
||||
.await
|
||||
.expect("STARTTLS listener");
|
||||
Ok(())
|
||||
let starttls_handle = tokio::spawn(async move {
|
||||
server::listen_starttls(host, cfg.insecure_port, certs)
|
||||
.await
|
||||
.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