62 lines
1.2 KiB
Rust
62 lines
1.2 KiB
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>,
|
|
|
|
#[structopt (long)]
|
|
config_path: Option <PathBuf>,
|
|
|
|
#[structopt (long)]
|
|
asset_root: Option <PathBuf>,
|
|
|
|
#[structopt (long)]
|
|
print_tripcode: bool,
|
|
}
|
|
|
|
fn main () -> Result <(), Box <dyn 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: ptth::server::ConfigFile = ptth::load_toml::load (&path);
|
|
|
|
if opt.print_tripcode {
|
|
println! (r#""{}" = "{}""#, config_file.name, config_file.tripcode ());
|
|
return Ok (());
|
|
}
|
|
|
|
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 move {
|
|
ptth::server::run_server (
|
|
config_file,
|
|
ptth::graceful_shutdown::init (),
|
|
Some (path),
|
|
opt.asset_root
|
|
).await
|
|
})?;
|
|
|
|
Ok (())
|
|
}
|