Skip to content

Commit ff38e8d

Browse files
fix(procmgr): align manager reload path after stack rebase onto main
1 parent f74bf34 commit ff38e8d

3 files changed

Lines changed: 36 additions & 20 deletions

File tree

Cargo.lock

Lines changed: 20 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/procmgr/rust/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ nix = { workspace = true, features = ["signal", "process", "user"] }
6969

7070
[dev-dependencies]
7171
tempfile.workspace = true
72+
hyper-util = { workspace = true, features = ["tokio"] }
7273

7374
[[test]]
7475
name = "e2e"

pkg/procmgr/rust/src/manager.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
@@ -906,7 +909,10 @@ fn queue_restart(proc: &mut ManagedProcess, restart_tx: &mpsc::Sender<PendingRes
906909
}
907910
}
908911

909-
fn try_spawn_and_watch(proc: &mut ManagedProcess, exit_tx: &mpsc::Sender<ExitEvent>) -> Result<()> {
912+
fn try_spawn_and_watch(
913+
proc: &mut ManagedProcess,
914+
exit_tx: &mpsc::Sender<ExitEvent>,
915+
) -> Result<()> {
910916
proc.spawn()?;
911917
spawn_watcher(proc, exit_tx.clone());
912918
Ok(())
@@ -1147,16 +1153,14 @@ mod tests {
11471153
"reload should start the process with fresh counters"
11481154
);
11491155

1150-
mgr.complete_restart(stale_pending, &exit_tx, &restart_tx)
1151-
.await;
1156+
mgr.complete_restart(stale_pending, &exit_tx, &restart_tx).await;
11521157
let pid = mgr.processes().await[0].pid().unwrap();
11531158
test_helpers::cleanup_process(pid);
11541159
Ok(())
11551160
}
11561161

11571162
#[tokio::test]
1158-
async fn test_reload_discards_pending_retry_for_failed_auto_start_false() -> anyhow::Result<()>
1159-
{
1163+
async fn test_reload_discards_pending_retry_for_failed_auto_start_false() -> anyhow::Result<()> {
11601164
let (cmd, _args) = test_helpers::sleep_cmd(60);
11611165
let make_def = |secs: u32| ProcessDefinition {
11621166
name: "action-executor".to_string(),
@@ -1203,8 +1207,7 @@ mod tests {
12031207
mgr.handle_reload_config(&exit_tx, &restart_tx).await?;
12041208
assert!(!mgr.processes().await[0].is_running());
12051209

1206-
mgr.complete_restart(stale_pending, &exit_tx, &restart_tx)
1207-
.await;
1210+
mgr.complete_restart(stale_pending, &exit_tx, &restart_tx).await;
12081211
assert!(
12091212
!mgr.processes().await[0].is_running(),
12101213
"config reload should discard pending crash retries for failed auto_start=false processes"

0 commit comments

Comments
 (0)