From 7659e433eb73e1f33ddac49537bfa5dfaa124875 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 11 Jul 2025 13:00:50 -0600 Subject: refactor: merge the server and cli into a single binary --- src/bin/cli.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/bin/cli.rs') diff --git a/src/bin/cli.rs b/src/bin/cli.rs index fc70ae82..7b18cc3b 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -38,6 +38,11 @@ enum Commands { )] host: String, }, + Server { + /// Address to bind to + #[arg(short, long, env = "BIND_ADDR")] + addr: String, + }, } #[tokio::main] @@ -63,6 +68,24 @@ async fn main() -> Result<(), Box> { output ); } + Commands::Server { addr } => { + tracing_subscriber::fmt() + .json() + .with_max_level(tracing::Level::INFO) + .with_current_span(true) + .with_span_list(true) + .with_target(true) + .with_thread_ids(true) + .with_thread_names(true) + .with_file(true) + .with_line_number(true) + .init(); + + tracing::info!(address = %addr, "Starting authorization server"); + let cedar = authzd::authorization::CedarAuthorizer::default(); + let server = authzd::authorization::Server::new(cedar)?; + server.serve(addr.parse().unwrap()).await?; + } } Ok(()) -- cgit v1.2.3 From e7015c080181eba17296d0dc678b0e5578fadc15 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 11 Jul 2025 13:09:33 -0600 Subject: chore: provide default value for bind addr and fix Procfile --- Procfile | 2 +- src/bin/cli.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/bin/cli.rs') diff --git a/Procfile b/Procfile index 8062bf67..39bbbeaf 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -authzd: ./bin/authzd +authzd: ./bin/authzd server envoy: ./bin/envoy -c ./etc/envoy/envoy.yaml --base-id 1 --log-level warn --component-log-level admin:warn,connection:warn,grpc:warn,http:warn,http2:warn,router:warn,upstream:warn diff --git a/src/bin/cli.rs b/src/bin/cli.rs index 7b18cc3b..6f089353 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -40,7 +40,7 @@ enum Commands { }, Server { /// Address to bind to - #[arg(short, long, env = "BIND_ADDR")] + #[arg(short, long, env = "BIND_ADDR", default_value = "127.0.0.1:50051")] addr: String, }, } @@ -82,9 +82,9 @@ async fn main() -> Result<(), Box> { .init(); tracing::info!(address = %addr, "Starting authorization server"); - let cedar = authzd::authorization::CedarAuthorizer::default(); - let server = authzd::authorization::Server::new(cedar)?; - server.serve(addr.parse().unwrap()).await?; + authzd::authorization::Server::new(authzd::authorization::CedarAuthorizer::default())? + .serve(addr.parse().unwrap()) + .await?; } } -- cgit v1.2.3