ptth/src/bin/ptth_server.rs

45 lines
857 B
Rust

use std::{
error::Error,
path::PathBuf,
};
use structopt::StructOpt;
use tokio::runtime;
use tracing::debug;
#[derive (Debug, StructOpt)]
struct Opt {
#[structopt (long)]
file_server_root: Option <PathBuf>,
}
fn main () -> Result <(), Box <dyn Error>> {
tracing_subscriber::fmt::init ();
let path = PathBuf::from ("./config/ptth_server.toml");
let config_file: ptth::server::ConfigFile = ptth::load_toml::load (&path);
let mut rt = if false {
debug! ("Trying to use less RAM");
runtime::Builder::new ()
.threaded_scheduler ()
.enable_all ()
.core_threads (1)
.thread_stack_size (1024 * 1024)
.build ()?
}
else {
runtime::Runtime::new ()?
};
rt.block_on (async {
ptth::server::run_server (
config_file,
ptth::graceful_shutdown::init (),
Some (path)
).await
})?;
Ok (())
}