add additional logging
All checks were successful
CI / lint (push) Successful in 16s
CI / fuzz (push) Successful in 1m37s
CI / test (push) Successful in 20s

This commit is contained in:
Kamal Tufekcic 2026-07-27 11:22:21 +03:00
commit 4ec5535f77

View file

@ -1205,25 +1205,36 @@ pub(crate) fn launch_bots_server(
logpath.display()
);
}
if let Ok(live) = live::LiveProcess::attach(pid)
&& let Some(base) = live.base(lib)
{
let insts = live.find_instances(ready_vt.slot0 + base, 64);
let ready = match pawn_health {
Some(health) => insts
.into_iter()
.any(|o| live.read_i32(o + health).unwrap_or(0) > 0),
None => !insts.is_empty(),
};
if ready {
return Ok(OwnedServer { child, pid }); // ready — detach the poll handle, hand off the child
}
}
// Each failure mode records WHY. Reporting only "not ready" conflates three very different causes —
// memory unreadable, the library never mapped, and the instance simply not spawned yet — and leaves
// the operator guessing at which.
let why = match live::LiveProcess::attach(pid) {
Err(e) => format!("cannot read pid {pid}'s memory: {e:#}"),
Ok(live) => match live.base(lib) {
None => format!("{lib} is not mapped in pid {pid}"),
Some(base) => {
let insts = live.find_instances(ready_vt.slot0 + base, 64);
let ready = match pawn_health {
Some(health) => insts
.iter()
.any(|&o| live.read_i32(o + health).unwrap_or(0) > 0),
None => !insts.is_empty(),
};
if ready {
return Ok(OwnedServer { child, pid }); // ready — hand off the child
}
match pawn_health {
Some(_) => format!("{} instance(s) found, none alive", insts.len()),
None => "no instance found".to_string(),
}
}
},
};
if std::time::Instant::now() >= deadline {
let _ = child.kill();
let _ = child.wait();
anyhow::bail!(
"not ready within {wait}s — check {} (server up? map/bots loaded?)",
"not ready within {wait}s ({why}) — check {} (server up? map/bots loaded?)",
logpath.display()
);
}