#[cfg(all(not(target_env = "musl"), feature = "jemalloc"))]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
use anyhow::Result;
use clap::Parser;
use iocaine::{app::Iocaine, cli, config::Config};
#[tokio::main]
async fn main() -> Result<()> {
#[cfg(all(feature = "tokio-console", not(tokio_unstable)))]
compile_error!(
"`tokio-console` requires manually enabling the `--cfg tokio_unstable` rust flag during compilation!"
);
#[cfg(all(feature = "tokio-console", tokio_unstable))]
console_subscriber::init();
#[cfg(not(all(feature = "tokio-console", tokio_unstable)))]
tracing_subscriber::fmt()
.with_max_level(tracing::Level::WARN)
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.with_writer(std::io::stderr)
.init();
let args = cli::Args::parse();
tracing::debug!(config_file = &args.config_file, "loading configuration");
let config = Config::load(&args.config_file).unwrap_or_else(|err| panic!("{}", err));
let app = Iocaine::new(config)?;
app.run().await?;
Ok(())
}