mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
## Why Detached launches truncate stderr logs, losing details from previous failures. Updater handoffs can also leave existing writers with stale offsets after truncation. ## What changed - Record daemon lifecycle and update stages with timings, outcomes, and typed OS errors, omitting error messages and context. - Preserve the last 256 KiB of nonempty stderr logs before truncation and use append handles to prevent gaps during handoff. Preservation failures do not block launch. - Attach current and previous updater log tails when log inclusion is enabled for a report, with a 512 KiB total limit and legacy filename fallback. Skip missing, empty, and nonregular files. ## Testing Add regression coverage for diagnostic error redaction, bounded log preservation, append behavior during handoff, attachment selection, and updater logs in captured report uploads. GitOrigin-RevId: 918317022ab9dcfd1b13d676872706c77e9ffbb2
58 lines
1.4 KiB
Rust
58 lines
1.4 KiB
Rust
mod pid;
|
|
mod stderr_log;
|
|
#[cfg(windows)]
|
|
pub(crate) mod windows;
|
|
|
|
use std::collections::BTreeMap;
|
|
use std::path::Path;
|
|
use std::path::PathBuf;
|
|
|
|
use serde::Serialize;
|
|
|
|
pub(crate) use pid::PidBackend;
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum BackendKind {
|
|
Pid,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub(crate) struct BackendPaths {
|
|
pub(crate) codex_bin: PathBuf,
|
|
pub(crate) pid_file: PathBuf,
|
|
pub(crate) update_pid_file: PathBuf,
|
|
pub(crate) remote_control_enabled: bool,
|
|
pub(crate) feature_overrides: BTreeMap<String, bool>,
|
|
}
|
|
|
|
pub(crate) fn pid_backend(paths: BackendPaths) -> PidBackend {
|
|
let mut backend = PidBackend::new(
|
|
paths.codex_bin,
|
|
paths.pid_file,
|
|
paths.remote_control_enabled,
|
|
);
|
|
backend.feature_overrides = paths.feature_overrides;
|
|
backend
|
|
}
|
|
|
|
pub(crate) fn pid_update_loop_backend(paths: BackendPaths) -> PidBackend {
|
|
PidBackend::new_update_loop(
|
|
paths.codex_bin,
|
|
paths.update_pid_file,
|
|
/*restore_release*/ None,
|
|
)
|
|
}
|
|
|
|
pub(crate) async fn append_stderr_log_tail_context(pid_file: &Path, context: &mut String) {
|
|
match pid::read_stderr_log_tail(pid_file).await {
|
|
Ok(Some(tail)) => tail.append_to_context(context),
|
|
Ok(None) => {}
|
|
Err(err) => {
|
|
context.push_str(&format!(
|
|
"\n\nFailed to read managed app-server stderr log: {err:#}"
|
|
));
|
|
}
|
|
}
|
|
}
|