mirror of
https://github.com/openai/codex.git
synced 2026-11-20 23:08:21 +00:00
Support managed daemon updates on Windows (#42392)
## What changed - Run the daemon update loop on Windows using the non-interactive PowerShell installer. - Restart the managed app server after updates and hand updater ownership to a changed managed executable through a readiness handshake. - Contain installer descendants in a Windows job while allowing app-server and successor updater processes to break away. - Preserve or restore PID ownership when successor startup fails, without terminating a process that reused the PID. ## Testing - Cover non-interactive installer success and script failure on Windows. - Cover updater handoff, readiness, rollback, inaccessible processes, and PID reuse. GitOrigin-RevId: 5178c01124b4dd86b507b53f5093ec9a9d48e12c
This commit is contained in:
1 parent
fe140d4c8e
commit
91608236ea
9 files changed
+469
-90
No files matched your search
@@ -1,21 +1,14 @@
|
||||
//! Resolves packaged and legacy standalone install layouts.
|
||||
//! Resolves both package and legacy standalone layouts and compares installed executables.
|
||||
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(unix)]
|
||||
use anyhow::Context;
|
||||
#[cfg(unix)]
|
||||
use anyhow::Result;
|
||||
#[cfg(unix)]
|
||||
use anyhow::anyhow;
|
||||
#[cfg(unix)]
|
||||
use sha2::Digest;
|
||||
#[cfg(unix)]
|
||||
use sha2::Sha256;
|
||||
#[cfg(unix)]
|
||||
use tokio::fs;
|
||||
#[cfg(unix)]
|
||||
use tokio::process::Command;
|
||||
|
||||
/// Returns the packaged executable when present, otherwise an existing legacy executable.
|
||||
@@ -37,7 +30,6 @@ pub(crate) fn managed_codex_bin(codex_home: &Path) -> PathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub(crate) async fn resolved_managed_codex_bin(codex_bin: &Path) -> Result<PathBuf> {
|
||||
fs::canonicalize(codex_bin).await.with_context(|| {
|
||||
format!(
|
||||
@@ -47,18 +39,16 @@ pub(crate) async fn resolved_managed_codex_bin(codex_bin: &Path) -> Result<PathB
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub(crate) async fn managed_codex_version(codex_bin: &Path) -> Result<String> {
|
||||
let output = Command::new(codex_bin)
|
||||
.arg("--version")
|
||||
.output()
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed to invoke managed Codex binary {}",
|
||||
codex_bin.display()
|
||||
)
|
||||
})?;
|
||||
let mut command = Command::new(codex_bin);
|
||||
#[cfg(windows)]
|
||||
command.creation_flags(windows_sys::Win32::System::Threading::CREATE_NO_WINDOW);
|
||||
let output = command.arg("--version").output().await.with_context(|| {
|
||||
format!(
|
||||
"failed to invoke managed Codex binary {}",
|
||||
codex_bin.display()
|
||||
)
|
||||
})?;
|
||||
if !output.status.success() {
|
||||
return Err(anyhow!(
|
||||
"managed Codex binary {} exited with status {}",
|
||||
@@ -76,13 +66,11 @@ pub(crate) async fn managed_codex_version(codex_bin: &Path) -> Result<String> {
|
||||
parse_codex_version(&stdout)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub(crate) struct ExecutableIdentity {
|
||||
digest: [u8; 32],
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub(crate) async fn executable_identity(executable: &Path) -> Result<ExecutableIdentity> {
|
||||
let bytes = fs::read(executable)
|
||||
.await
|
||||
@@ -90,7 +78,6 @@ pub(crate) async fn executable_identity(executable: &Path) -> Result<ExecutableI
|
||||
Ok(executable_identity_from_bytes(&bytes))
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub(crate) fn executable_identity_from_bytes(bytes: &[u8]) -> ExecutableIdentity {
|
||||
ExecutableIdentity {
|
||||
digest: Sha256::digest(bytes).into(),
|
||||
@@ -101,7 +88,6 @@ fn managed_codex_file_name() -> &'static str {
|
||||
if cfg!(windows) { "codex.exe" } else { "codex" }
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn parse_codex_version(output: &str) -> Result<String> {
|
||||
let version = output
|
||||
.split_whitespace()
|
||||
@@ -111,7 +97,7 @@ fn parse_codex_version(output: &str) -> Result<String> {
|
||||
Ok(version.to_string())
|
||||
}
|
||||
|
||||
#[cfg(all(test, unix))]
|
||||
#[cfg(test)]
|
||||
#[path = "managed_install_tests.rs"]
|
||||
mod tests;
|
||||
|
||||
|
||||
Reference in new issue
Block a user