fix(host): what holds the books is known, not guessed; a command joins what starts beside it
Plan P15 unit A5, fix round. A server answering its admin socket with no host over it was taken to be "the app". Three wrong outcomes followed: a `serve` started while a killed host's server was still finishing its last backup was told "the app has these books open" and exited, `close` and `doctor` said "the app" during such a close, and a command attached to another command's short-lived server as if it were the app (refused "not open" for another company, or its server closed under the other). A server now says what it is. `wanderbooks server --started-by app|host|command` writes run/server.info beside its lock (who started it, its pid, whether it has begun to close), moved into place whole as soon as the lock is its, rewritten `closing` the moment it is told to close, removed just before the lock goes. It is read only while the lock is held, which is when it is the lock holder's. A file beside the lock, not a field in the admin hello: it also covers a server that has no admin socket yet (opening) and costs the older admin protocol nothing. A server that says nothing (an earlier build's) is taken for the app's, as before. `opener::what_holds` reads it: only a server the app started, not closing and answering, is the app. A command's server, or one that is closing (the app's, or the orphan of a host that went), is waited for, said in words, bounded by `open_wait` (a bridge waits as long as its session does), and the holder or command goes on once it is gone. `close`, `doctor` and the bridge say the true thing for each. A command racing another program's start no longer fails with "close it" or waits silently 300 s: if its own server loses the lock to a program that started after its look, it lets its start go and joins what runs (`wait_ready_unless_beaten`, `reach`), inside one `open_wait`. A command's own server is started clean, as a host is: the host's environment only, the root as an absolute path, `/` as its folder (Windows: `run/`), and every server closes the descriptors above 2 at its start, so one that outlives its command (still closing after 90 s) holds none of the invoker's pipes. The app's own child keeps its environment: it is the window's child, closes with the window and needs the user's session (ssh agent, git configuration) for backups; it too loses stray descriptors, since the server does that for any starter. Test knobs: `--start-delay` (a server's slow start) and `timer_hold=1` for a command's own server, following `--timer-hold`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
6b95ce59ad
commit
2ff2913274
9 files changed
+598
-80
No files matched your search
@@ -258,6 +258,24 @@ fn host_env(
|
||||
env
|
||||
}
|
||||
|
||||
/// Give `command` the environment a host has (INVARIANT 1) and nothing of
|
||||
/// this process's: the books server a command runs for itself is started
|
||||
/// so, as the host's own is, since it may outlive the command that
|
||||
/// started it (commands.rs `reach`).
|
||||
pub(crate) fn clean_environment(command: &mut Command) -> Result<(), String> {
|
||||
let home = ledger_store::root::account_home().map_err(|e| e.to_string())?;
|
||||
command.env_clear();
|
||||
#[cfg(unix)]
|
||||
command.envs(host_env(
|
||||
&home,
|
||||
std::env::var_os("SSH_AUTH_SOCK").as_deref(),
|
||||
this_appimage().as_ref(),
|
||||
));
|
||||
#[cfg(windows)]
|
||||
command.envs(host_env(&home));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
/// Whether this process sits in a unit under this account's user manager
|
||||
/// (an app's scope or service, as uwsm makes for every app), whose stop
|
||||
|
||||
Reference in new issue
Block a user