#[cfg(feature = "jemalloc")]
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
use fuel_core_bin::cli;
use std::time::Duration;
const RUNTIME_SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(5);
#[cfg(feature = "rocksdb")]
fn disable_coredump_unless_opted_in() {
let opted_in = std::env::var("FUEL_CORE_ENABLE_COREDUMP")
.ok()
.map(|v| {
matches!(
v.trim().to_ascii_lowercase().as_str(),
"1" | "true" | "yes" | "on"
)
})
.unwrap_or(false);
if opted_in {
return;
}
if let Err(e) = rlimit::setrlimit(rlimit::Resource::CORE, 0, 0) {
eprintln!("Warning: failed to disable coredumps: {e}");
}
}
fn main() -> anyhow::Result<()> {
#[cfg(feature = "rocksdb")]
disable_coredump_unless_opted_in();
let runtime = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?;
let result = runtime.block_on(cli::run_cli());
runtime.shutdown_timeout(RUNTIME_SHUTDOWN_TIMEOUT);
result
}