ptth/crates/ptth_quic/src/bin/ptth_quic_relay_server.rs

31 lines
592 B
Rust

use tokio::sync::watch;
use ptth_quic::prelude::*;
#[tokio::main]
async fn main () -> anyhow::Result <()> {
use structopt::StructOpt;
tracing_subscriber::fmt::init ();
let opt = ptth_quic::executable_relay_server::Opt::from_args ();
let (running_tx, mut running_rx) = watch::channel (true);
ctrlc::set_handler (move || {
running_tx.send (false).expect ("Couldn't forward Ctrl+C signal");
})?;
trace! ("Set Ctrl+C handler");
tokio::select! {
val = ptth_quic::executable_relay_server::main (opt) => {
},
val = running_rx.changed () => {
},
}
Ok (())
}