@@ -989,6 +989,7 @@ async fn server_main(config: Config) -> eyre::Result<()> {
989
989
let load_chunks_parallelism = config. load_chunks_parallelism ;
990
990
let db_chunks_bucket_name = config. db_chunks_bucket_name . clone ( ) ;
991
991
let db_chunks_folder_name = config. db_chunks_folder_name . clone ( ) ;
992
+ let download_shutdown_handler = Arc :: clone ( & shutdown_handler) ;
992
993
993
994
let ( tx, rx) = oneshot:: channel ( ) ;
994
995
background_tasks. spawn_blocking ( move || {
@@ -1068,6 +1069,7 @@ async fn server_main(config: Config) -> eyre::Result<()> {
1068
1069
"Initialize iris db: Loading from DB (parallelism: {})" ,
1069
1070
parallelism
1070
1071
) ;
1072
+ let download_shutdown_handler = Arc :: clone ( & download_shutdown_handler) ;
1071
1073
let s3_store = S3Store :: new ( s3_client_clone, db_chunks_bucket_name) ;
1072
1074
tokio:: runtime:: Handle :: current ( ) . block_on ( async {
1073
1075
let mut stream = match config. enable_s3_importer {
@@ -1199,6 +1201,10 @@ async fn server_main(config: Config) -> eyre::Result<()> {
1199
1201
elapsed,
1200
1202
record_counter as f64 / elapsed. as_secs_f64( )
1201
1203
) ;
1204
+ if download_shutdown_handler. is_shutting_down ( ) {
1205
+ tracing:: warn!( "Shutdown requested by shutdown_handler." ) ;
1206
+ return Err ( eyre:: eyre!( "Shutdown requested" ) ) ;
1207
+ }
1202
1208
}
1203
1209
1204
1210
// if the serial id hasn't been loaded before, count is as unique record
@@ -1282,7 +1288,7 @@ async fn server_main(config: Config) -> eyre::Result<()> {
1282
1288
let sns_client_bg = sns_client. clone ( ) ;
1283
1289
let config_bg = config. clone ( ) ;
1284
1290
let store_bg = store. clone ( ) ;
1285
- let shutdown_handler_bg = shutdown_handler . clone ( ) ;
1291
+ let shutdown_handler_bg = Arc :: clone ( & shutdown_handler ) ;
1286
1292
let _result_sender_abort = background_tasks. spawn ( async move {
1287
1293
while let Some ( ServerJobResult {
1288
1294
merged_results,
0 commit comments