@team-agent/installer 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/crates/team-agent/src/coordinator/health.rs +63 -3
- package/package.json +4 -4
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
//! coordinator 健康/身份 & 只读可观测面:metadata 身份原语 + coordinator 路径 + watch 实时流。
|
|
2
2
|
|
|
3
3
|
use std::io::{Read, Seek, SeekFrom};
|
|
4
|
+
#[cfg(unix)]
|
|
5
|
+
use std::os::unix::process::CommandExt;
|
|
4
6
|
use std::path::{Path, PathBuf};
|
|
5
7
|
use std::process::{Command, Stdio};
|
|
6
8
|
use std::time::Duration;
|
|
@@ -96,13 +98,15 @@ pub fn start_coordinator(workspace: &WorkspacePath) -> Result<StartReport, Start
|
|
|
96
98
|
.append(true)
|
|
97
99
|
.open(&log_path)?;
|
|
98
100
|
let log_err = log.try_clone()?;
|
|
99
|
-
let
|
|
101
|
+
let mut command = Command::new(std::env::current_exe()?);
|
|
102
|
+
command
|
|
100
103
|
.args(["coordinator", "--workspace"])
|
|
101
104
|
.arg(workspace.as_path())
|
|
102
105
|
.stdin(Stdio::null())
|
|
103
106
|
.stdout(Stdio::from(log))
|
|
104
|
-
.stderr(Stdio::from(log_err))
|
|
105
|
-
|
|
107
|
+
.stderr(Stdio::from(log_err));
|
|
108
|
+
detach_daemon_child(&mut command);
|
|
109
|
+
let child = command.spawn()?;
|
|
106
110
|
let pid = Pid::new(child.id());
|
|
107
111
|
std::fs::write(coordinator_pid_path(workspace), pid.to_string())?;
|
|
108
112
|
write_coordinator_metadata(workspace, pid, MetadataSource::Start)?;
|
|
@@ -116,6 +120,24 @@ pub fn start_coordinator(workspace: &WorkspacePath) -> Result<StartReport, Start
|
|
|
116
120
|
})
|
|
117
121
|
}
|
|
118
122
|
|
|
123
|
+
#[cfg(unix)]
|
|
124
|
+
fn detach_daemon_child(command: &mut Command) {
|
|
125
|
+
// The coordinator is a daemon: it must not remain in the launcher's process
|
|
126
|
+
// group, otherwise bare SSH command teardown can SIGHUP it after quick-start exits.
|
|
127
|
+
unsafe {
|
|
128
|
+
command.pre_exec(|| {
|
|
129
|
+
if libc::setsid() == -1 {
|
|
130
|
+
Err(std::io::Error::last_os_error())
|
|
131
|
+
} else {
|
|
132
|
+
Ok(())
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
#[cfg(not(unix))]
|
|
139
|
+
fn detach_daemon_child(_command: &mut Command) {}
|
|
140
|
+
|
|
119
141
|
/// `stop_coordinator`(`lifecycle.py:228-247`):SIGTERM pid + 清 pid/meta → typed report。
|
|
120
142
|
pub fn stop_coordinator(workspace: &WorkspacePath) -> Result<StopReport, StopError> {
|
|
121
143
|
let pid_path = coordinator_pid_path(workspace);
|
|
@@ -696,3 +718,41 @@ fn clean_text(text: &str) -> String {
|
|
|
696
718
|
fn prefix_chars(text: &str, max: usize) -> String {
|
|
697
719
|
text.chars().take(max).collect()
|
|
698
720
|
}
|
|
721
|
+
|
|
722
|
+
#[cfg(all(test, unix))]
|
|
723
|
+
mod tests {
|
|
724
|
+
use super::*;
|
|
725
|
+
|
|
726
|
+
struct ChildGuard(std::process::Child);
|
|
727
|
+
|
|
728
|
+
impl Drop for ChildGuard {
|
|
729
|
+
fn drop(&mut self) {
|
|
730
|
+
unsafe {
|
|
731
|
+
libc::kill(self.0.id() as libc::pid_t, libc::SIGTERM);
|
|
732
|
+
}
|
|
733
|
+
let _ = self.0.wait();
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
#[test]
|
|
738
|
+
fn coordinator_daemon_spawn_helper_detaches_session() {
|
|
739
|
+
let mut command = Command::new("/bin/sleep");
|
|
740
|
+
command
|
|
741
|
+
.arg("30")
|
|
742
|
+
.stdin(Stdio::null())
|
|
743
|
+
.stdout(Stdio::null())
|
|
744
|
+
.stderr(Stdio::null());
|
|
745
|
+
detach_daemon_child(&mut command);
|
|
746
|
+
|
|
747
|
+
let child = command.spawn().expect("spawn detached child");
|
|
748
|
+
let guard = ChildGuard(child);
|
|
749
|
+
let pid = guard.0.id() as libc::pid_t;
|
|
750
|
+
let sid = unsafe { libc::getsid(pid) };
|
|
751
|
+
|
|
752
|
+
assert_ne!(sid, -1, "getsid({pid}) failed");
|
|
753
|
+
assert_eq!(
|
|
754
|
+
sid, pid,
|
|
755
|
+
"detached coordinator children must become session leaders so launcher SIGHUP does not reach them"
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@team-agent/installer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "npx installer for Team Agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codex",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"team-agent-installer": "npm/install.mjs"
|
|
21
21
|
},
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@team-agent/cli-darwin-arm64": "0.3.
|
|
24
|
-
"@team-agent/cli-darwin-x64": "0.3.
|
|
25
|
-
"@team-agent/cli-linux-x64": "0.3.
|
|
23
|
+
"@team-agent/cli-darwin-arm64": "0.3.12",
|
|
24
|
+
"@team-agent/cli-darwin-x64": "0.3.12",
|
|
25
|
+
"@team-agent/cli-linux-x64": "0.3.12"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"postinstall": "node npm/bincheck.mjs",
|