#![warn (clippy::pedantic)] use std::{ path::PathBuf, }; use structopt::StructOpt; use tokio::runtime; use ptth_server::{ ConfigFile, load_toml, run_server, }; #[derive (Debug, StructOpt)] struct Opt { //#[structopt (long)] //file_server_root: Option , #[structopt (long)] config_path: Option , #[structopt (long)] asset_root: Option , #[structopt (long)] print_tripcode: bool, } fn main () -> Result <(), anyhow::Error> { let opt = Opt::from_args (); tracing_subscriber::fmt::init (); let path = opt.config_path.clone ().unwrap_or_else (|| PathBuf::from ("./config/ptth_server.toml")); let config_file: ConfigFile = load_toml::load (&path)?; if opt.print_tripcode { println! (r#"name = "{}""#, config_file.name); println! (r#"tripcode = "{}""#, config_file.tripcode ()); return Ok (()); } let rt = runtime::Runtime::new ()?; rt.block_on (async move { run_server ( config_file, ptth_core::graceful_shutdown::init (), Some (path), opt.asset_root ).await })?; Ok (()) }