2 Commits

Author SHA1 Message Date
0fe043acb5 Revert "Use store instead of fetch_add for atomics"
All checks were successful
Build and deploy / Build container and manifests (push) Successful in 6m1s
This reverts commit d4bd0ef1ca.
2025-04-21 02:21:18 +02:00
878df8da40 Start graceful shutdown on SIGTERM
All checks were successful
Build and deploy / Build container and manifests (push) Successful in 5m32s
2025-04-20 00:58:18 +02:00
2 changed files with 20 additions and 3 deletions

View File

@@ -19,15 +19,15 @@ pub struct Stats {
impl Stats {
pub fn add_connection(&self) {
self.connections.store(1, Ordering::Relaxed);
self.connections.fetch_add(1, Ordering::Relaxed);
}
pub fn add_rx_bytes(&self, n: usize) {
self.rx.store(n, Ordering::Relaxed);
self.rx.fetch_add(n, Ordering::Relaxed);
}
pub fn add_tx_bytes(&self, n: usize) {
self.tx.store(n, Ordering::Relaxed);
self.tx.fetch_add(n, Ordering::Relaxed);
}
pub fn connections(&self) -> usize {

View File

@@ -20,11 +20,28 @@ use tracing_subscriber::EnvFilter;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
#[cfg(unix)]
async fn sigterm() {
use tokio::signal::unix::SignalKind;
let mut sigterm =
tokio::signal::unix::signal(SignalKind::terminate()).expect("should be able to initialize");
sigterm.recv().await;
}
#[cfg(not(unix))]
async fn sigterm() {
std::future::pending::<()>().await;
}
async fn shutdown_task(token: CancellationToken) {
select! {
_ = tokio::signal::ctrl_c() => {
debug!("Received SIGINT");
}
_ = sigterm() => {
debug!("Received SIGTERM");
}
_ = token.cancelled() => {
debug!("Application called for graceful shutdown");
}