#![forbid(unsafe_code)]
#![deny(warnings)]
#![deny(rust_2018_idioms)]
#![deny(dead_code)]
#[cfg(all(target_env = "musl", target_pointer_width = "64"))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
use static_web_server::Result;
fn main() -> Result {
use static_web_server::settings::Commands;
use static_web_server::Settings;
let opts = Settings::get()?;
if let Some(commands) = opts.general.commands {
match commands {
Commands::Install {} => {
#[cfg(windows)]
return static_web_server::winservice::install_service();
#[cfg(unix)]
println!("ignored: `install` command is only available for Windows");
}
Commands::Uninstall {} => {
#[cfg(windows)]
return static_web_server::winservice::uninstall_service();
#[cfg(unix)]
println!("ignored: `uninstall` command is only available for Windows");
}
}
} else if opts.general.as_windows_service {
#[cfg(windows)]
return static_web_server::winservice::run_server_as_service();
#[cfg(unix)]
println!("ignored: `--as-windows-service` option is only available for Windows");
}
static_web_server::Server::new(None)?.run()?;
Ok(())
}