@@ -163,6 +163,16 @@ fn main() {
163163 std:: env:: set_var ( "RUST_BACKTRACE" , "1" ) ;
164164 }
165165
166+ // Install signal handlers early to avoid missing signals during startup
167+ // This is a best-effort approach - actual signal handling happens in the async context
168+ #[ cfg( unix) ]
169+ {
170+ // Pre-install signal handlers to reduce the window where signals might be missed
171+ if let Err ( err) = signal:: unix:: signal ( signal:: unix:: SignalKind :: terminate ( ) ) {
172+ tracing:: warn!( "Failed to pre-install SIGTERM handler during startup: {}" , err) ;
173+ }
174+ }
175+
166176 if let Err ( err) = Cli :: < EthereumChainSpecParser , RollkitArgs > :: parse ( ) . run (
167177 async move |builder, rollkit_args| {
168178 info ! ( "=== EV-RETH: Starting with args: {:?} ===" , rollkit_args) ;
@@ -226,8 +236,11 @@ fn main() {
226236 // If we can't handle any signals, we should still shut down gracefully
227237 // This prevents the application from hanging indefinitely
228238 tracing:: warn!( "No signal handling available, shutdown will only occur on natural node exit" ) ;
229- // Wait indefinitely - this branch should rarely be reached
230- std:: future:: pending :: < ( ) > ( ) . await ;
239+ // Use a long sleep instead of pending forever to allow periodic status checks
240+ loop {
241+ tokio:: time:: sleep ( Duration :: from_secs ( 86400 ) ) . await ; // Wake up daily
242+ tracing:: info!( "=== EV-RETH: Daily status check - node still running ===" ) ;
243+ }
231244 }
232245 }
233246 }
@@ -244,8 +257,11 @@ fn main() {
244257 Err ( err) => {
245258 tracing:: error!( "Failed to wait for SIGINT: {}" , err) ;
246259 tracing:: warn!( "No signal handling available, shutdown will only occur on natural node exit" ) ;
247- // Wait indefinitely - this branch should rarely be reached
248- std:: future:: pending :: < ( ) > ( ) . await ;
260+ // Use a long sleep instead of pending forever to allow periodic status checks
261+ loop {
262+ tokio:: time:: sleep ( Duration :: from_secs ( 86400 ) ) . await ; // Wake up daily
263+ tracing:: info!( "=== EV-RETH: Daily status check - node still running ===" ) ;
264+ }
249265 }
250266 }
251267 }
@@ -263,8 +279,14 @@ fn main() {
263279 // Structured shutdown phases for better observability
264280 info!( "=== EV-RETH: Phase 1 - Stopping new connections ===" ) ;
265281
266- // Initiate graceful shutdown with timeout
267- let shutdown_timeout = Duration :: from_secs( 30 ) ;
282+ // Initiate graceful shutdown with configurable timeout
283+ let shutdown_timeout = Duration :: from_secs(
284+ std:: env:: var( "EV_RETH_SHUTDOWN_TIMEOUT_SECS" )
285+ . ok( )
286+ . and_then( |s| s. parse( ) . ok( ) )
287+ . unwrap_or( 30 )
288+ ) ;
289+ info!( "=== EV-RETH: Using shutdown timeout of {:?} ===" , shutdown_timeout) ;
268290
269291 info!( "=== EV-RETH: Phase 2 - Draining active requests ===" ) ;
270292
0 commit comments