From 3a95f58b40f323114eabfa36d95280f7246c8ff0 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:55:01 -0700 Subject: [PATCH] Just get raw std env vars --- src/aspen/main.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/aspen/main.rs b/src/aspen/main.rs index 8e0923db..8f0d8ca2 100644 --- a/src/aspen/main.rs +++ b/src/aspen/main.rs @@ -154,24 +154,18 @@ async fn spawn(fut: impl Future + Send + 'static) { tokio::spawn(fut); } -#[derive(Parser, Debug)] -struct Args { - alpenrosethreadcount: usize, - channels: usize, -} - #[tokio::main] async fn main() -> anyhow::Result<()> { // Worker Id for this instance of Aspen let this_worker_id = Arc::new(Uuid::new_v4().to_string()); + let channel_count = std::env::var("CHANNELS").expect("channels not set").parse::().expect("channels not a number"); + let alpenrosethreadcount = std::env::var("ALPENROSETHREADCOUNT").expect("alpenrosethreadcount not set").parse::().expect("alpenrosethreadcount not a number"); + //connect to postgres let conn_pool: CatenaryPostgresPool = make_async_pool().await.unwrap(); let arc_conn_pool: Arc = Arc::new(conn_pool); - let args = Args::parse(); - //init_tracing("Tarpc Example Server")?; - let tailscale_ip = catenary::tailscale::interface().expect("no tailscale interface found"); let server_addr = (tailscale_ip, 40427); @@ -212,7 +206,7 @@ async fn main() -> anyhow::Result<()> { let authoritative_gtfs_rt_store = Arc::clone(&raw_gtfs); let authoritative_data_store = Arc::clone(&authoritative_data_store); let conn_pool = Arc::clone(&arc_conn_pool); - let thread_count = args.alpenrosethreadcount.clone(); + let thread_count = alpenrosethreadcount.clone(); move || async move { async_threads_alpenrose::alpenrose_process_threads( alpenrose_to_process_queue, @@ -242,7 +236,7 @@ async fn main() -> anyhow::Result<()> { channel.execute(server.serve()).for_each(spawn) }) // Max n channels. - .buffer_unordered(args.channels) + .buffer_unordered(channel_count) .for_each(|_| async {}) .await;