1#![warn(missing_docs)]
2use std::sync::Arc;
12
13use fedimint_core::fedimint_build_code_version_env;
14use fedimint_core::util::handle_version_hash_command;
15use fedimint_gateway_server::Gateway;
16use fedimint_logging::{LOG_GATEWAY, TracingSetup};
17#[cfg(not(any(target_env = "msvc", target_os = "ios", target_os = "android")))]
18use tikv_jemallocator::Jemalloc;
19use tracing::info;
20
21#[cfg(not(any(target_env = "msvc", target_os = "ios", target_os = "android")))]
22#[global_allocator]
23static GLOBAL: Jemalloc = Jemalloc;
25
26fn main() -> Result<(), anyhow::Error> {
27 let runtime = Arc::new(tokio::runtime::Runtime::new()?);
28 runtime.block_on(async {
29 handle_version_hash_command(fedimint_build_code_version_env!());
30 TracingSetup::default().init()?;
31 let (mnemonic_sender, mnemonic_receiver) = tokio::sync::broadcast::channel::<()>(4);
32 let gatewayd = Gateway::new_with_default_modules(mnemonic_sender).await?;
33 let shutdown_receiver = gatewayd
34 .clone()
35 .run(runtime.clone(), mnemonic_receiver)
36 .await?;
37 shutdown_receiver.await;
38 gatewayd.unannounce_from_all_federations().await;
39 info!(target: LOG_GATEWAY, "Gatewayd exiting...");
40 Ok(())
41 })
42}