@@ -83,14 +83,11 @@ impl ProcessManager {
8383 let mut procs = self . processes . write ( ) . await ;
8484 for & idx in order. iter ( ) {
8585 let proc = & mut procs[ idx] ;
86- if proc. may_auto_start ( ) {
87- match proc. spawn ( ) {
88- Ok ( ( ) ) => spawn_watcher ( proc, exit_tx. clone ( ) ) ,
89- Err ( e) => {
90- warn ! ( "{e:#}" ) ;
91- queue_restart ( proc, restart_tx) ;
92- }
93- }
86+ if proc. may_auto_start ( )
87+ && let Err ( e) = try_spawn_and_watch ( proc, exit_tx)
88+ {
89+ warn ! ( "{e:#}" ) ;
90+ queue_restart ( proc, restart_tx) ;
9491 }
9592 proc. record_config_gate_met ( ) ;
9693 }
@@ -905,10 +902,7 @@ fn queue_restart(proc: &mut ManagedProcess, restart_tx: &mpsc::Sender<PendingRes
905902 }
906903}
907904
908- fn try_spawn_and_watch (
909- proc : & mut ManagedProcess ,
910- exit_tx : & mpsc:: Sender < ExitEvent > ,
911- ) -> Result < ( ) > {
905+ fn try_spawn_and_watch ( proc : & mut ManagedProcess , exit_tx : & mpsc:: Sender < ExitEvent > ) -> Result < ( ) > {
912906 proc. spawn ( ) ?;
913907 spawn_watcher ( proc, exit_tx. clone ( ) ) ;
914908 Ok ( ( ) )
@@ -1149,14 +1143,16 @@ mod tests {
11491143 "reload should start the process with fresh counters"
11501144 ) ;
11511145
1152- mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx) . await ;
1146+ mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx)
1147+ . await ;
11531148 let pid = mgr. processes ( ) . await [ 0 ] . pid ( ) . unwrap ( ) ;
11541149 test_helpers:: cleanup_process ( pid) ;
11551150 Ok ( ( ) )
11561151 }
11571152
11581153 #[ tokio:: test]
1159- async fn test_reload_discards_pending_retry_for_failed_auto_start_false ( ) -> anyhow:: Result < ( ) > {
1154+ async fn test_reload_discards_pending_retry_for_failed_auto_start_false ( ) -> anyhow:: Result < ( ) >
1155+ {
11601156 let ( cmd, _args) = test_helpers:: sleep_cmd ( 60 ) ;
11611157 let make_def = |secs : u32 | ProcessDefinition {
11621158 name : "action-executor" . to_string ( ) ,
@@ -1203,7 +1199,8 @@ mod tests {
12031199 mgr. handle_reload_config ( & exit_tx, & restart_tx) . await ?;
12041200 assert ! ( !mgr. processes( ) . await [ 0 ] . is_running( ) ) ;
12051201
1206- mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx) . await ;
1202+ mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx)
1203+ . await ;
12071204 assert ! (
12081205 !mgr. processes( ) . await [ 0 ] . is_running( ) ,
12091206 "config reload should discard pending crash retries for failed auto_start=false processes"
0 commit comments