Files
nym/nym-statistics-api/src/main.rs
T
Jędrzej Stuczyński 0ee387d983 Feature/cancellation migration (#6014)
* squashing work on using cancellation in nym crates

making nym-task wasm compilable

removed sending of status messages

replaced TaskManager with ShutdownManager in the validator rewarder

additional helpers for ShutdownManager

simplified ShutdownToken by removing the name field

TaskClient => ShutdownToken within all client tasks

wip: remove TaskHandle

* track all long-living client tasks

* add task tracking for most top level tasks within nym-node

* improved default builder

* split up cancellation module

* module documentation and unit tests

* nym node fixes and naming consistency

* wasm fixes

* assert_eq => assert

* wasm fixes and made 'run_until_shutdown' take reference instead of ownership

* linux-specific fixes to IpPacketRouter

* post rebasing fixes for signing monitor

* add ShutdownManager constructor to build it from an external token

* applying PR review suggestions
2025-09-10 13:56:39 +01:00

53 lines
1.4 KiB
Rust

use clap::Parser;
use network_view::NetworkRefresher;
use nym_task::ShutdownManager;
mod cli;
mod http;
mod logging;
mod network_view;
mod storage;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
logging::setup_tracing_logger()?;
let args = cli::Cli::parse();
let connection_url = args.database_url.clone();
tracing::debug!("Using config:\n{:#?}", args);
let storage = storage::StatisticsStorage::init(
connection_url,
args.username,
args.password,
args.pg_port,
args.ssl_cert_path,
)
.await?;
tracing::info!("Connection to database successful");
let mut shutdown_manager = ShutdownManager::build_new_default()?;
let network_refresher =
NetworkRefresher::initialise_new(args.nym_api_url, shutdown_manager.child_shutdown_token())
.await;
let http_server =
http::server::build_http_api(storage, network_refresher.network_view(), args.http_port)
.await
.expect("Failed to build http server");
let server_shutdown = shutdown_manager.clone_shutdown_token();
// Starting tasks
shutdown_manager.spawn(async move { http_server.run(server_shutdown).await });
network_refresher.start();
tracing::info!("Started HTTP server on port {}", args.http_port);
shutdown_manager.close_tracker();
shutdown_manager.run_until_shutdown().await;
Ok(())
}