codemp/server/src/main.rs

46 lines
958 B
Rust
Raw Normal View History

//! # codemp Server
//!
//! The codemp server itself, in charge of handling the global state, merging operations from
//! all clients and synching everyone's cursor.
//!
2023-04-12 04:59:33 +02:00
use clap::Parser;
use tracing::info;
use tonic::transport::Server;
2023-04-12 04:59:33 +02:00
mod buffer;
use crate::buffer::service::BufferService;
2022-07-10 19:01:56 +02:00
2023-04-12 04:59:33 +02:00
#[derive(Parser, Debug)]
struct CliArgs {
/// address to listen on
#[arg(long, default_value = "[::1]:50051")]
host: String,
/// enable debug log level
#[arg(long, default_value_t = false)]
debug: bool,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
2023-04-12 04:59:33 +02:00
let args = CliArgs::parse();
2023-04-12 04:59:33 +02:00
tracing_subscriber::fmt()
.with_writer(std::io::stdout)
.with_max_level(if args.debug { tracing::Level::DEBUG } else { tracing::Level::INFO })
.init();
2023-07-01 19:04:10 +02:00
info!(">> codemp server");
info!("binding on {}", args.host);
2022-07-10 19:01:56 +02:00
Server::builder()
.add_service(BufferService::new().server())
2023-04-12 04:59:33 +02:00
.serve(args.host.parse()?)
.await?;
2022-07-10 19:01:56 +02:00
Ok(())
2022-07-10 19:01:56 +02:00
}