ptth/src/bin/ptth_relay.rs

45 lines
829 B
Rust

use std::{
error::Error,
path::PathBuf,
sync::Arc,
};
use tracing::{info};
use tracing_subscriber::{
fmt,
fmt::format::FmtSpan,
EnvFilter,
};
use ptth::relay;
use ptth::relay::{
Config,
RelayState,
};
#[tokio::main]
async fn main () -> Result <(), Box <dyn Error>> {
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?;
info! ("ptth_relay Git version: {:?}", ptth::git_version::GIT_VERSION);
let (shutdown_rx, forced_shutdown) = ptth::graceful_shutdown::init_with_force ();
forced_shutdown.wrap_server (
relay::run_relay (
Arc::new (RelayState::from (config)),
shutdown_rx,
Some (config_path)
)
).await??;
Ok (())
}