Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ aws-smithy-http = "0.54"
aws-smithy-types = "0.54"
aws-types = "0.54"
axum = { version = "0.6", features = ["headers"] }
clap = { version = "4.2.1", features = ["derive", "env"] }
http = "*"
hyper = { version = "0.14", features = ["full"] }
maligned = "0.2.1"
Expand Down
18 changes: 16 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
//! * [ndarray] provides [NumPy](https://numpy.orgq)-like n-dimensional arrays used in numerical
//! computation.

use clap::Parser;
use tokio::signal;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

Expand All @@ -34,15 +35,28 @@ mod operations;
mod s3_client;
mod validated_json;

/// S3 Active Storage Proxy command line interface
#[derive(Debug, Parser)]
struct CommandLineArgs {
/// The IP address on which the proxy should listen
#[arg(long, default_value = "0.0.0.0", env = "S3_ACTIVE_STORAGE_HOST")]
host: String,
/// The port to which the proxy should bind
#[arg(long, default_value_t = 8080, env = "S3_ACTIVE_STORAGE_PORT")]
port: u16,
}

/// Application entry point
#[tokio::main]
async fn main() {
let args = CommandLineArgs::parse();

init_tracing();

let router = app::router();

// run it with hyper on localhost:8080
axum::Server::bind(&"0.0.0.0:8080".parse().unwrap())
// run it with hyper
axum::Server::bind(&format!("{}:{}", args.host, args.port).parse().unwrap())
.serve(router.into_make_service())
.with_graceful_shutdown(shutdown_signal())
.await
Expand Down