Skip to content

Commit

Permalink
Just get raw std env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Apr 23, 2024
1 parent 5f96a59 commit 3a95f58
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/aspen/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,18 @@ async fn spawn(fut: impl Future<Output = ()> + 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::<usize>().expect("channels not a number");
let alpenrosethreadcount = std::env::var("ALPENROSETHREADCOUNT").expect("alpenrosethreadcount not set").parse::<usize>().expect("alpenrosethreadcount not a number");

//connect to postgres
let conn_pool: CatenaryPostgresPool = make_async_pool().await.unwrap();
let arc_conn_pool: Arc<CatenaryPostgresPool> = 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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 3a95f58

Please sign in to comment.