Fix cleanup config handling

This commit is contained in:
lemon-sh 2022-01-21 13:27:44 +01:00
parent 21d8edbef1
commit 5aebcc1fce
2 changed files with 13 additions and 12 deletions

18
Cargo.lock generated
View File

@ -488,9 +488,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.112"
version = "0.2.113"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9"
[[package]]
name = "libsqlite3-sys"
@ -884,18 +884,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.133"
version = "1.0.134"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"
checksum = "96b3c34c1690edf8174f5b289a336ab03f568a4460d8c6df75f2f3a692b3bc6a"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.133"
version = "1.0.134"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"
checksum = "784ed1fbfa13fe191077537b0d70ec8ad1e903cfe04831da608aa36457cb653d"
dependencies = [
"proc-macro2",
"quote",
@ -961,9 +961,9 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
[[package]]
name = "socket2"
version = "0.4.2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516"
checksum = "0f82496b90c36d70af5fcd482edaa2e0bd16fade569de1330405fecbbdac736b"
dependencies = [
"libc",
"winapi",
@ -1391,7 +1391,7 @@ dependencies = [
[[package]]
name = "xuproxy"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"anyhow",
"hex",

View File

@ -70,14 +70,15 @@ async fn main() -> anyhow::Result<()> {
let (ctx, _) = broadcast::channel(1);
let server_task = tokio::spawn(run_server(config.clone(), db_conn.clone(), ctx.subscribe()));
let cleanup_task = tokio::spawn(cleanup_task(db_conn, config, ctx.subscribe()));
let cleanup_task = config.cleanup.map(|_| tokio::spawn(cleanup_task(db_conn, config, ctx.subscribe())));
terminate_signal().await;
info!("Shutdown signal received, powering down");
let _ = ctx.send(());
server_task.await
.unwrap_or_else(|e| error!("Couldn't await the server task: {}", e));
cleanup_task.await
.unwrap_or_else(|e| error!("Couldn't await the cleanup task: {}", e));
if let Some(t) = cleanup_task {
t.await.unwrap_or_else(|e| error!("Couldn't await the cleanup task: {}", e));
}
executor_thread.join().unwrap();
Ok(())
}