mirror of
https://github.com/openai/codex.git
synced 2026-11-20 23:08:21 +00:00
Persist loaded threads before managed daemon shutdown (#44283)
## Why Loaded threads, including idle threads whose rollout files are still deferred, need to survive a managed daemon restart. Shutdown must also remain forceable when rollout I/O is blocked. ## What changed - Add a hidden `--managed-daemon` option for app-server Unix socket transports. After active turns and admitted requests drain, save loaded persistent root threads before exiting. - Skip ephemeral threads, non-root agent threads, and threads pending unload. Log persistence failures and continue saving other threads. - Apply shutdown admission checks to thread and turn settings updates, thread deletion, and archiving. - Keep force signals and daemon shutdown requests responsive during persistence. Return `AppServerExit::Forced` so executables can exit without waiting for runtime teardown. ## Testing Add integration coverage for resuming active and idle threads after restart, forcing shutdown during active work, and forcing shutdown with a blocked rollout writer. Extend shutdown rejection coverage to deletion and settings updates. GitOrigin-RevId: 4344e97d39f9f80c5d84c41c17300fd6aa99b4cc
This commit is contained in:
1 parent
fcd90d8f07
commit
c1840dc55e
12 files changed
+465
-16
No files matched your search
@@ -577,6 +577,10 @@ struct AppServerCommand {
|
||||
#[arg(long = "remote-control", hide = true)]
|
||||
remote_control: bool,
|
||||
|
||||
/// Save loaded threads during managed daemon shutdown.
|
||||
#[arg(long, hide = true)]
|
||||
managed_daemon: bool,
|
||||
|
||||
/// Controls whether analytics are enabled by default.
|
||||
///
|
||||
/// Analytics are disabled by default for app-server. Users have to explicitly opt in
|
||||
@@ -1319,6 +1323,7 @@ async fn cli_main(
|
||||
listen,
|
||||
stdio,
|
||||
remote_control,
|
||||
managed_daemon,
|
||||
analytics_default_enabled,
|
||||
auth,
|
||||
} = app_server_cli;
|
||||
@@ -1339,6 +1344,7 @@ async fn cli_main(
|
||||
let auth = auth.try_into_settings()?;
|
||||
let runtime_options = codex_app_server::AppServerRuntimeOptions {
|
||||
code_mode_host_transport: code_mode_host.into(),
|
||||
managed_daemon,
|
||||
remote_control_startup_mode: match (remote_control, remote_control_disabled)
|
||||
{
|
||||
(true, _) => {
|
||||
@@ -1353,7 +1359,7 @@ async fn cli_main(
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
codex_app_server::run_main_with_transport_options(
|
||||
let exit = codex_app_server::run_main_with_transport_options(
|
||||
arg0_paths.clone(),
|
||||
root_config_overrides,
|
||||
LoaderOverrides::default(),
|
||||
@@ -1365,6 +1371,10 @@ async fn cli_main(
|
||||
runtime_options,
|
||||
)
|
||||
.await?;
|
||||
if exit == codex_app_server::AppServerExit::Forced {
|
||||
// Runtime teardown can wait forever for blocked rollout I/O.
|
||||
std::process::exit(0);
|
||||
}
|
||||
}
|
||||
Some(AppServerSubcommand::Daemon(daemon_cli)) => match daemon_cli.subcommand {
|
||||
AppServerDaemonSubcommand::Start => {
|
||||
|
||||
Reference in new issue
Block a user