@@ -258,29 +258,36 @@ fn main() {
258258 result
259259 }
260260 _ = shutdown_signal => {
261- info!( "=== EV-RETH: Shutdown signal received, stopping node ===" ) ;
261+ info!( "=== EV-RETH: Shutdown signal received, initiating graceful shutdown ===" ) ;
262+
263+ // Structured shutdown phases for better observability
264+ info!( "=== EV-RETH: Phase 1 - Stopping new connections ===" ) ;
262265
263266 // Initiate graceful shutdown with timeout
264267 let shutdown_timeout = Duration :: from_secs( 30 ) ;
265268
266- // Get a reference to the node exit future before dropping the handle
267- let mut node_exit_future = handle. node_exit_future;
268-
269- // Drop the handle to trigger shutdown
270- drop( handle) ;
269+ info!( "=== EV-RETH: Phase 2 - Draining active requests ===" ) ;
271270
272271 // Wait for the node to actually exit with a timeout
273- let shutdown_result = timeout( shutdown_timeout, node_exit_future) . await ;
272+ // We use the handle's node_exit_future directly to avoid partial move issues
273+ let shutdown_result = timeout( shutdown_timeout, handle. node_exit_future) . await ;
274+
275+ info!( "=== EV-RETH: Phase 3 - Shutdown completed ===" ) ;
274276
275277 match shutdown_result {
276278 Ok ( result) => {
277279 info!( "=== EV-RETH: Node shutdown completed gracefully ===" ) ;
278280 result
279281 }
280282 Err ( _) => {
281- tracing:: warn!( "=== EV-RETH: Node shutdown timed out after {:?} ===" , shutdown_timeout) ;
282- info!( "=== EV-RETH: Forcing application exit ===" ) ;
283- Ok ( ( ) )
283+ tracing:: error!( "=== EV-RETH: Node shutdown timed out after {:?} ===" , shutdown_timeout) ;
284+ tracing:: error!( "=== EV-RETH: Forcing application exit - this may indicate a shutdown issue ===" ) ;
285+ // Return an error to indicate that shutdown didn't complete gracefully
286+ // This provides better error reporting for monitoring systems
287+ Err ( Box :: new( std:: io:: Error :: new(
288+ std:: io:: ErrorKind :: TimedOut ,
289+ format!( "Node shutdown timed out after {:?}" , shutdown_timeout)
290+ ) ) as Box <dyn std:: error:: Error + Send + Sync >)
284291 }
285292 }
286293 }
0 commit comments