diff --git a/bin/reth/src/runner.rs b/bin/reth/src/runner.rs index d0a171f33d..a7ee1ca9f5 100644 --- a/bin/reth/src/runner.rs +++ b/bin/reth/src/runner.rs @@ -3,6 +3,7 @@ use futures::pin_mut; use reth_tasks::{TaskExecutor, TaskManager}; use std::future::Future; +use tokio::signal::unix::SignalKind; use tracing::trace; /// Used to execute cli commands @@ -116,16 +117,23 @@ where async fn run_until_ctrl_c(fut: F) -> Result<(), E> where F: Future>, - E: Send + Sync + 'static, + E: Send + Sync + 'static + From, { + let mut stream = tokio::signal::unix::signal(SignalKind::terminate())?; + let sigterm = stream.recv(); + let ctrl_c = tokio::signal::ctrl_c(); pin_mut!(ctrl_c, fut); + pin_mut!(sigterm, fut); tokio::select! { _ = ctrl_c => { trace!(target: "reth::cli", "Received ctrl-c"); }, + _ = sigterm => { + trace!(target: "reth::cli", "Received SIGTERM"); + }, res = fut => res?, }