Skip to content

Commit 9ac530e

Browse files
committed
Move CLI initialization into async main
1 parent 5877c82 commit 9ac530e

1 file changed

Lines changed: 17 additions & 20 deletions

File tree

quickwit/quickwit-cli/src/main.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use quickwit_cli::metrics::register_build_info_metric;
2424
use quickwit_cli::{busy_detector, install_default_crypto_ring_provider};
2525
use quickwit_common::runtimes::scrape_tokio_runtime_metrics;
2626
use quickwit_serve::BuildInfo;
27-
use quickwit_telemetry_exporters::TelemetryHandle;
2827
use tracing::error;
2928

3029
/// The main tokio runtime takes num_cores / 3 threads by default, and can be overridden by the
@@ -46,8 +45,6 @@ fn main() -> anyhow::Result<()> {
4645
openssl_probe::init_openssl_env_vars()
4746
};
4847

49-
let (command, ansi_colors) = parse_cli_command();
50-
5148
let main_runtime_num_threads: usize = get_main_runtime_num_threads();
5249
let rt = tokio::runtime::Builder::new_multi_thread()
5350
.enable_all()
@@ -58,22 +55,7 @@ fn main() -> anyhow::Result<()> {
5855
.build()
5956
.context("failed to start main Tokio runtime")?;
6057

61-
rt.block_on(async move {
62-
install_default_crypto_ring_provider();
63-
64-
let build_info = BuildInfo::get();
65-
let telemetry_handle = quickwit_telemetry_exporters::init_telemetry(
66-
&build_info.version,
67-
command.default_log_level(),
68-
ansi_colors,
69-
)?;
70-
register_build_info_metric(build_info);
71-
72-
let runtime_handle = tokio::runtime::Handle::current();
73-
scrape_tokio_runtime_metrics(&runtime_handle, "main");
74-
75-
main_impl(command, telemetry_handle).await
76-
})
58+
rt.block_on(main_impl())
7759
}
7860

7961
fn parse_cli_command() -> (CliCommand, bool) {
@@ -94,7 +76,22 @@ fn parse_cli_command() -> (CliCommand, bool) {
9476
(command, ansi_colors)
9577
}
9678

97-
async fn main_impl(command: CliCommand, telemetry_handle: TelemetryHandle) -> anyhow::Result<()> {
79+
async fn main_impl() -> anyhow::Result<()> {
80+
let (command, ansi_colors) = parse_cli_command();
81+
82+
install_default_crypto_ring_provider();
83+
84+
let build_info = BuildInfo::get();
85+
let telemetry_handle = quickwit_telemetry_exporters::init_telemetry(
86+
&build_info.version,
87+
command.default_log_level(),
88+
ansi_colors,
89+
)?;
90+
register_build_info_metric(build_info);
91+
92+
let runtime_handle = tokio::runtime::Handle::current();
93+
scrape_tokio_runtime_metrics(&runtime_handle, "main");
94+
9895
#[cfg(feature = "jemalloc")]
9996
start_jemalloc_metrics_loop();
10097

0 commit comments

Comments
 (0)