feat(server): add gitks gRPC server with environment configuration
- Add dotenvy dependency for environment variable loading - Integrate tracing-subscriber for structured logging - Create main.rs entry point with async server initialization - Implement environment-based host and port configuration - Set default address to 0.0.0:50051 for gRPC server - Add proper error handling with Box<dyn std::error::Error>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
use gitks::server::serve;
|
||||
|
||||
const DEFAULT_HOST: &str = "0.0.0.0";
|
||||
const DEFAULT_PORT: &str = "50051";
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
dotenvy::dotenv().ok();
|
||||
tracing_subscriber::fmt::init();
|
||||
let host = std::env::var("GITKS_HOST").unwrap_or_else(|_| DEFAULT_HOST.into());
|
||||
let port = std::env::var("GITKS_PORT").unwrap_or_else(|_| DEFAULT_PORT.into());
|
||||
let addr: std::net::SocketAddr = format!("{host}:{port}").parse()?;
|
||||
tracing::info!("starting gitks gRPC server on {addr}");
|
||||
serve(addr).await?;
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user