@@ -567,10 +567,18 @@ pub async fn run<'a>(
567567) -> anyhow:: Result < DatasetRows > {
568568 let mut processes_to_observe = exec_plan. external_processes_to_observe . unwrap_or ( vec ! [ ] ) ; // external procs to observe are cloned here.
569569
570+ // Set as minimum grace period, keeping it to stay backwards compatibile
571+ let mut max_grace_millis = 2000_u64 ;
570572 // run the application if there is anything to run
571573 if !exec_plan. processes_to_execute . is_empty ( ) {
572574 for proc in exec_plan. processes_to_execute {
573575 print ! ( "> starting process {}" , proc. name. green( ) ) ;
576+ if let Some ( startup_grace) = proc. startup_grace {
577+ let millis = startup_grace. as_millis ( ) as u64 ;
578+ if millis > max_grace_millis {
579+ max_grace_millis = millis;
580+ }
581+ }
574582
575583 let process_to_observe = run_process ( proc) ?;
576584
@@ -581,9 +589,9 @@ pub async fn run<'a>(
581589 }
582590 }
583591
584- print ! ( "> waiting for application to settle" ) ;
592+ print ! ( "> waiting for application to settle: {}ms" , max_grace_millis ) ;
585593 std:: io:: stdout ( ) . flush ( ) ?;
586- tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 2000 ) ) . await ;
594+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( max_grace_millis ) ) . await ;
587595 println ! ( " {}" , "\t ✓" . green( ) ) ;
588596
589597 let start_time = Utc :: now ( ) . timestamp_millis ( ) ;
@@ -810,6 +818,7 @@ pub mod tests {
810818 down : None ,
811819 redirect : Some ( Redirect :: Null ) ,
812820 process_type : ProcessType :: BareMetal ,
821+ startup_grace : None ,
813822 } ;
814823 let proc_to_observe = run_process ( & proc) ?;
815824
@@ -843,6 +852,7 @@ pub mod tests {
843852 down : None ,
844853 redirect : Some ( Redirect :: Null ) ,
845854 process_type : ProcessType :: BareMetal ,
855+ startup_grace : None ,
846856 } ;
847857 let procs_to_observe = run_process ( & proc) ?;
848858 let stop_handle = metrics_logger:: start_logging ( vec ! [ procs_to_observe] ) ?;
0 commit comments