mod config; mod grpc; use crate::config::CONFIG; use clap::{Parser, Subcommand}; use log::{debug, info}; use tonic::transport::Server; // Import generated protobuf mod sched { tonic::include_proto!("sched"); // pub(crate) const FILE_DESCRIPTOR_SET: FileDescriptorSet = // tonic::include_file_descriptor_set!("protocol_descriptor").into(); } #[derive(Parser)] #[command(author, version, about)] #[command(propagate_version = true)] struct Cli { #[command(subcommand)] command: Option<Commands>, #[arg(short, long)] /// Optional path to config file config_file: Option<String>, } #[derive(Subcommand)] enum Commands { /// Starts uwusched Start { role: Option<String> }, } fn get_type_of<T>(_: &T) -> &'static str { std::any::type_name::<T>() } #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { std::env::set_var("RUST_LOG", CONFIG.log.level.clone()); pretty_env_logger::init(); let addr = "[::1]:50051".parse()?; info!("Starting gRPC server on {}", addr); let data = grpc::DataService::default(); let auth = grpc::AuthService::default(); // let reflection = tonic_reflection::server::Builder::configure() // .register_file_descriptor_set(sched::FILE_DESCRIPTOR_SET) // .build_v1()?; Server::builder() .add_service(sched::data_server::DataServer::new(data)) .add_service(sched::auth_server::AuthServer::new(auth)) .serve(addr) .await?; debug!("{:?}", CONFIG.node); // let cli = Cli::parse(); // match &cli.command { // Some(Commands::Start { role }) => { // debug!("{:#?}", role) // } // None => {} // } Ok(()) }