PR: #51 (feat/23-testnet-config)
File: crates/charon-cli/src/main.rs (run_listen tokio::select! block, line 180)
Refs #51
Problem
The tokio::select! in run_listen handles SIGINT only:
tokio::select! {
_ = async { ... } => info!("all listeners exited"),
_ = tokio::signal::ctrl_c() => info!("ctrl-c received, shutting down"),
}
docker stop sends SIGTERM (not SIGINT). kubectl delete pod sends SIGTERM. systemd stop sends SIGTERM. All of these terminate the Tokio runtime without running the shutdown branch — open WS connections are not closed, in-flight DashMap writes may be interrupted, Prometheus metrics server is killed mid-scrape.
First flagged in PR #30 review (finding 4). This PR's stated deployment context (Docker Compose for Grafana demo) makes SIGTERM handling load-bearing: the demo workflow is docker compose up / docker compose down, and down sends SIGTERM.
Impact
Ungraceful shutdown on every docker compose down cycle. Potential partial state in DashMap if scan is mid-upsert when SIGTERM arrives.
Fix
#[cfg(unix)]
{
use tokio::signal::unix::{signal, SignalKind};
let mut sigterm = signal(SignalKind::terminate())?;
tokio::select! {
_ = async { ... } => info!("all listeners exited"),
_ = tokio::signal::ctrl_c() => info!("ctrl-c received, shutting down"),
_ = sigterm.recv() => info!("sigterm received, shutting down"),
}
}
tokio::signal::unix is Unix-only; wrap in #[cfg(unix)].
PR: #51 (feat/23-testnet-config)
File: crates/charon-cli/src/main.rs (run_listen tokio::select! block, line 180)
Refs #51
Problem
The
tokio::select!inrun_listenhandles SIGINT only:docker stopsends SIGTERM (not SIGINT).kubectl delete podsends SIGTERM.systemd stopsends SIGTERM. All of these terminate the Tokio runtime without running the shutdown branch — open WS connections are not closed, in-flight DashMap writes may be interrupted, Prometheus metrics server is killed mid-scrape.First flagged in PR #30 review (finding 4). This PR's stated deployment context (Docker Compose for Grafana demo) makes SIGTERM handling load-bearing: the demo workflow is
docker compose up / docker compose down, anddownsends SIGTERM.Impact
Ungraceful shutdown on every
docker compose downcycle. Potential partial state in DashMap if scan is mid-upsert when SIGTERM arrives.Fix
tokio::signal::unixis Unix-only; wrap in#[cfg(unix)].