mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-07-26 07:58:14 +00:00
refactor: manualy build tokio runtime for garage
to allow do some initialization before
This commit is contained in:
+15
-8
@@ -63,8 +63,7 @@ struct Opt {
|
|||||||
cmd: Command,
|
cmd: Command,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
fn main() {
|
||||||
async fn main() {
|
|
||||||
// Initialize version and features info
|
// Initialize version and features info
|
||||||
let features = &[
|
let features = &[
|
||||||
#[cfg(feature = "bundled-libs")]
|
#[cfg(feature = "bundled-libs")]
|
||||||
@@ -145,7 +144,20 @@ async fn main() {
|
|||||||
|
|
||||||
sodiumoxide::init().expect("Unable to init sodiumoxide");
|
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::Server => server::run_server(opt.config_file, opt.secrets).await,
|
||||||
Command::OfflineRepair(repair_opt) => {
|
Command::OfflineRepair(repair_opt) => {
|
||||||
cli::local::repair::offline_repair(opt.config_file, opt.secrets, repair_opt).await
|
cli::local::repair::offline_repair(opt.config_file, opt.secrets, repair_opt).await
|
||||||
@@ -166,11 +178,6 @@ async fn main() {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => cli_command(opt).await,
|
_ => cli_command(opt).await,
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(e) = res {
|
|
||||||
eprintln!("Error: {}", e);
|
|
||||||
std::process::exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user