@@ -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 }
@@ -909,10 +906,7 @@ fn queue_restart(proc: &mut ManagedProcess, restart_tx: &mpsc::Sender<PendingRes
909906 }
910907}
911908
912- fn try_spawn_and_watch (
913- proc : & mut ManagedProcess ,
914- exit_tx : & mpsc:: Sender < ExitEvent > ,
915- ) -> Result < ( ) > {
909+ fn try_spawn_and_watch ( proc : & mut ManagedProcess , exit_tx : & mpsc:: Sender < ExitEvent > ) -> Result < ( ) > {
916910 proc. spawn ( ) ?;
917911 spawn_watcher ( proc, exit_tx. clone ( ) ) ;
918912 Ok ( ( ) )
@@ -1153,14 +1147,16 @@ mod tests {
11531147 "reload should start the process with fresh counters"
11541148 ) ;
11551149
1156- mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx) . await ;
1150+ mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx)
1151+ . await ;
11571152 let pid = mgr. processes ( ) . await [ 0 ] . pid ( ) . unwrap ( ) ;
11581153 test_helpers:: cleanup_process ( pid) ;
11591154 Ok ( ( ) )
11601155 }
11611156
11621157 #[ tokio:: test]
1163- async fn test_reload_discards_pending_retry_for_failed_auto_start_false ( ) -> anyhow:: Result < ( ) > {
1158+ async fn test_reload_discards_pending_retry_for_failed_auto_start_false ( ) -> anyhow:: Result < ( ) >
1159+ {
11641160 let ( cmd, _args) = test_helpers:: sleep_cmd ( 60 ) ;
11651161 let make_def = |secs : u32 | ProcessDefinition {
11661162 name : "action-executor" . to_string ( ) ,
@@ -1207,7 +1203,8 @@ mod tests {
12071203 mgr. handle_reload_config ( & exit_tx, & restart_tx) . await ?;
12081204 assert ! ( !mgr. processes( ) . await [ 0 ] . is_running( ) ) ;
12091205
1210- mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx) . await ;
1206+ mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx)
1207+ . await ;
12111208 assert ! (
12121209 !mgr. processes( ) . await [ 0 ] . is_running( ) ,
12131210 "config reload should discard pending crash retries for failed auto_start=false processes"
0 commit comments