refactor: manualy build tokio runtime for garage

to allow do some initialization before
This commit is contained in:
Gwen Lg
2026-02-03 23:13:23 +01:00
parent b012431df0
commit ca1211d927
+15 -8
View File
@@ -63,8 +63,7 @@ struct Opt {
cmd: Command,
}
#[tokio::main]
async fn main() {
fn main() {
// Initialize version and features info
let features = &[
#[cfg(feature = "bundled-libs")]
@@ -145,7 +144,20 @@ async fn main() {
sodiumoxide::init().expect("Unable to init sodiumoxide");
let res = match opt.cmd {
let res = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.expect("build tokio multi_thread runtime failed")
.block_on(run(opt));
if let Err(e) = res {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
async fn run(opt: Opt) -> Result<(), Error> {
match opt.cmd {
Command::Server => server::run_server(opt.config_file, opt.secrets).await,
Command::OfflineRepair(repair_opt) => {
cli::local::repair::offline_repair(opt.config_file, opt.secrets, repair_opt).await
@@ -166,11 +178,6 @@ async fn main() {
Ok(())
}
_ => cli_command(opt).await,
};
if let Err(e) = res {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}