#![warn (clippy::pedantic)] use std::{ convert::TryFrom, error::Error, path::PathBuf, sync::Arc, }; use tracing::{info}; use tracing_subscriber::{ fmt, fmt::format::FmtSpan, EnvFilter, }; use ptth_relay::{ Config, git_version::read_git_version, RelayState, run_relay, }; #[tokio::main] async fn main () -> Result <(), Box > { fmt () .with_env_filter (EnvFilter::from_default_env ()) .with_span_events (FmtSpan::FULL) .init () ; let config_path = PathBuf::from ("config/ptth_relay.toml"); let config = Config::from_file (&config_path).await?; match read_git_version ().await { Some (x) => info! ("ptth_relay Git version: {:?}", x), None => info! ("ptth_relay not built from Git"), } let (shutdown_rx, forced_shutdown) = ptth_core::graceful_shutdown::init_with_force (); forced_shutdown.wrap_server ( run_relay ( Arc::new (RelayState::try_from (config)?), Arc::new (ptth_relay::load_templates (&PathBuf::new ())?), shutdown_rx, Some (config_path) ) ).await??; Ok (()) }