@@ -83,11 +83,14 @@ 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- && let Err ( e) = try_spawn_and_watch ( proc, exit_tx)
88- {
89- warn ! ( "{e:#}" ) ;
90- queue_restart ( proc, restart_tx) ;
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+ }
9194 }
9295 proc. record_config_gate_met ( ) ;
9396 }
@@ -902,7 +905,10 @@ fn queue_restart(proc: &mut ManagedProcess, restart_tx: &mpsc::Sender<PendingRes
902905 }
903906}
904907
905- fn try_spawn_and_watch ( proc : & mut ManagedProcess , exit_tx : & mpsc:: Sender < ExitEvent > ) -> Result < ( ) > {
908+ fn try_spawn_and_watch (
909+ proc : & mut ManagedProcess ,
910+ exit_tx : & mpsc:: Sender < ExitEvent > ,
911+ ) -> Result < ( ) > {
906912 proc. spawn ( ) ?;
907913 spawn_watcher ( proc, exit_tx. clone ( ) ) ;
908914 Ok ( ( ) )
@@ -1143,16 +1149,14 @@ mod tests {
11431149 "reload should start the process with fresh counters"
11441150 ) ;
11451151
1146- mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx)
1147- . await ;
1152+ mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx) . await ;
11481153 let pid = mgr. processes ( ) . await [ 0 ] . pid ( ) . unwrap ( ) ;
11491154 test_helpers:: cleanup_process ( pid) ;
11501155 Ok ( ( ) )
11511156 }
11521157
11531158 #[ tokio:: test]
1154- async fn test_reload_discards_pending_retry_for_failed_auto_start_false ( ) -> anyhow:: Result < ( ) >
1155- {
1159+ async fn test_reload_discards_pending_retry_for_failed_auto_start_false ( ) -> anyhow:: Result < ( ) > {
11561160 let ( cmd, _args) = test_helpers:: sleep_cmd ( 60 ) ;
11571161 let make_def = |secs : u32 | ProcessDefinition {
11581162 name : "action-executor" . to_string ( ) ,
@@ -1199,8 +1203,7 @@ mod tests {
11991203 mgr. handle_reload_config ( & exit_tx, & restart_tx) . await ?;
12001204 assert ! ( !mgr. processes( ) . await [ 0 ] . is_running( ) ) ;
12011205
1202- mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx)
1203- . await ;
1206+ mgr. complete_restart ( stale_pending, & exit_tx, & restart_tx) . await ;
12041207 assert ! (
12051208 !mgr. processes( ) . await [ 0 ] . is_running( ) ,
12061209 "config reload should discard pending crash retries for failed auto_start=false processes"
0 commit comments