Use nym task crate for network statistics signal handle (#3209)

* Use nym task crate for network statistics signal handle

* Update changelog
This commit is contained in:
Bogdan-Ștefan Neacşu
2023-03-22 16:43:00 +02:00
committed by GitHub
parent cfef9e96e6
commit c7020da81c
4 changed files with 12 additions and 9 deletions
+4
View File
@@ -4,6 +4,10 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
## [Unreleased]
- nym-network-statistics properly handles signals ([#3209])
[#3209]: https://github.com/nymtech/nym/issues/3209
## [v1.1.13] (2023-03-15)
- NE - instead of throwing a "Mixnode/Gateway not found" error for blacklisted nodes due to bad performance, show their history but tag them as "Having poor performance" ([#2979])
Generated
+1
View File
@@ -3601,6 +3601,7 @@ dependencies = [
"log",
"nym-bin-common",
"nym-statistics-common",
"nym-task",
"pretty_env_logger",
"rocket",
"serde",
@@ -16,6 +16,7 @@ thiserror = "1"
tokio = { version = "1.4", features = [ "net", "rt-multi-thread", "macros", "time" ] }
nym-bin-common = { path = "../../common/bin-common"}
nym-statistics-common = { path = "../../common/statistics" }
nym-task = { path = "../../common/task" }
[build-dependencies]
sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "sqlite", "macros", "migrate"] }
@@ -9,6 +9,7 @@ use error::Result;
use routes::{post_all_statistics, post_statistic};
use nym_statistics_common::api::STATISTICS_SERVICE_VERSION;
use nym_task::TaskManager;
mod error;
mod routes;
@@ -33,16 +34,12 @@ impl NetworkStatisticsAPI {
}
pub async fn run(self) {
let shutdown_handle = self.rocket.shutdown();
let rocket_shutdown_handle = self.rocket.shutdown();
let shutdown = TaskManager::new(10);
tokio::spawn(self.rocket.launch());
if let Err(e) = tokio::signal::ctrl_c().await {
error!(
"There was an error while capturing SIGINT - {:?}. We will terminate regardless",
e
);
}
info!("Received SIGINT - the network statistics API will terminate now");
shutdown_handle.notify();
shutdown.catch_interrupt().await.ok();
info!("Stopping network statistics");
rocket_shutdown_handle.notify();
}
}