File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,11 @@ static EXIT: LazyLock<CancellationToken> = LazyLock::new(CancellationToken::new)
7575/// grace period instead).
7676static SIGNAL_SHUTDOWN : AtomicBool = AtomicBool :: new ( false ) ;
7777
78+ /// Set when shutdown was triggered by a platform SIGTERM (an instance reclaim),
79+ /// as opposed to a local SIGINT (developer Ctrl-C). Distinguishes a reclaim
80+ /// from a manual stop for downstream shutdown handling.
81+ static PLATFORM_RECLAIM : AtomicBool = AtomicBool :: new ( false ) ;
82+
7883/// How long the platform gives this container between SIGTERM and SIGKILL.
7984/// Cloud Run defaults to 10 seconds (configurable up to 60 on the service);
8085/// keep this in sync with the platform setting via RIVET_SIGTERM_BUDGET_SECS.
@@ -417,7 +422,12 @@ fn spawn_signal_handler() {
417422 let mut sigterm = signal ( SignalKind :: terminate ( ) ) . expect ( "install SIGTERM handler" ) ;
418423 let mut sigint = signal ( SignalKind :: interrupt ( ) ) . expect ( "install SIGINT handler" ) ;
419424 tokio:: select! {
420- _ = sigterm. recv( ) => tracing:: info!( "received SIGTERM" ) ,
425+ _ = sigterm. recv( ) => {
426+ PLATFORM_RECLAIM . store( true , Ordering :: Release ) ;
427+ tracing:: warn!(
428+ "unexpected platform SIGTERM received, likely hitting OOM or running longer than 60 minutes"
429+ ) ;
430+ }
421431 _ = sigint. recv( ) => tracing:: info!( "received SIGINT" ) ,
422432 }
423433 SIGNAL_SHUTDOWN . store ( true , Ordering :: Release ) ;
You can’t perform that action at this time.
0 commit comments