From 4d1b5992ebf9f4d93e26a90cdedd9133e2a3d8ac Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Fri, 19 Apr 2024 15:02:52 +0100 Subject: [PATCH] custom runtime threads --- proxy/src/bin/proxy.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/proxy/src/bin/proxy.rs b/proxy/src/bin/proxy.rs index 0d86339f64..d16ca2bc45 100644 --- a/proxy/src/bin/proxy.rs +++ b/proxy/src/bin/proxy.rs @@ -35,6 +35,8 @@ use proxy::config::{self, ProxyConfig}; use proxy::serverless; use std::net::SocketAddr; use std::pin::pin; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; use std::sync::Arc; use tokio::net::TcpListener; use tokio::sync::Mutex; @@ -233,8 +235,21 @@ struct SqlOverHttpArgs { sql_over_http_pool_shards: usize, } -#[tokio::main] -async fn main() -> anyhow::Result<()> { +fn main() -> anyhow::Result<()> { + let rt = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .thread_name_fn(|| { + static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0); + let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst); + format!("worker-{}", id) + }) + .build() + .unwrap(); + + rt.block_on(main2()) +} + +async fn main2() -> anyhow::Result<()> { let _logging_guard = proxy::logging::init().await?; let _panic_hook_guard = utils::logging::replace_panic_hook_with_tracing_panic_hook(); let _sentry_guard = init_sentry(Some(GIT_VERSION.into()), &[]);