Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
29de444
test: run a real sshd per test behind a fault proxy
small-angel Nov 3, 2026
7963a9a
feat(host): add orx-host, a static per-run supervisor and RPC server
small-angel Nov 3, 2026
fc5c068
feat(engine): run every new run through one engine inside `orx up`
small-angel Nov 3, 2026
227f896
feat(ui): show engine run states, host contact and paged logs
small-angel Nov 3, 2026
cccc644
docs: describe the run engine in the architecture essays
small-angel Nov 3, 2026
18574d3
fix: distinguish pending run cancellation and confirm abandonment
small-angel Nov 3, 2026
c38a192
fix(engine): release rented boxes when cancelling or abandoning
small-angel Nov 3, 2026
e4b0a55
fix(ui): offer "Keep tracking" instead of "Cancel" when abandoning a run
small-angel Nov 3, 2026
bfb3ad2
fix(engine): cancel rentals after persistent SSH key rejection
small-angel Nov 3, 2026
ecb54a8
fix(engine): preserve legacy wakeups and completion log tails
small-angel Nov 3, 2026
1dd9ce5
test(engine): wait for host watchers before removing the rental test …
small-angel Nov 4, 2026
edfefbc
feat: put the run engine behind a setting
small-angel Nov 4, 2026
5bfdac4
fix(engine): API providers keep exit codes and report rejected creden…
small-angel Nov 4, 2026
827ade8
fix: second review round for the run engine setting
small-angel Nov 5, 2026
2c76586
fix(ui): run log and status polish
small-angel Nov 5, 2026
48cfa34
fix: bump the dashboard protocol for the engine's remote API
small-angel Nov 5, 2026
4cfaf9f
fix: embed the macOS orx-host in every release
small-angel Nov 5, 2026
c97876f
fix(engine): spawn engine processes the way a terminal would
small-angel Nov 5, 2026
c7efe51
fix(engine): detach the rental supervisor from the launching shell
small-angel Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(engine): detach the rental supervisor from the launching shell
Exec kills its command process group after the launcher exits. nohup leaves the rental supervisor in that group, so the engine kills it before the payload can start. Start the supervisor in its own session while keeping the redirected SSH pipes closed.

Assisted-by: gpt-6.1-sol
  • Loading branch information
small-angel committed Nov 5, 2026
commit c7efe5130e212321929590590644a3e813a34d9a
25 changes: 25 additions & 0 deletions crates/orx-host/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,29 @@ mod tests {
assert_eq!(result.signal, Some(libc::SIGKILL));
assert!(start.elapsed() < Duration::from_secs(2));
}

#[test]
fn detached_child_survives_command_group_cleanup() {
let dir = std::env::temp_dir().join(format!("orx-exec-detach-{}", crate::nonce().unwrap()));
std::fs::create_dir_all(&dir).unwrap();
let launch = "python3 -c 'import os,subprocess; os.setsid(); subprocess.Popen([\"/bin/sh\", \"-c\", \"sleep 0.2; echo survived > marker\"], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)'; exit $?";
let result = run(
Command::new("/bin/sh")
.args(["-c", launch])
.current_dir(&dir),
&[],
Duration::from_secs(2),
None,
)
.unwrap();
assert_eq!(result.code, Some(0), "{result:?}");
assert!(!result.timed_out);

let deadline = Instant::now() + Duration::from_secs(2);
while std::fs::read_to_string(dir.join("marker")).ok().as_deref() != Some("survived\n") {
assert!(Instant::now() < deadline, "detached child was killed");
std::thread::sleep(Duration::from_millis(10));
}
std::fs::remove_dir_all(&dir).unwrap();
}
}
92 changes: 65 additions & 27 deletions src/jobs/rental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,16 @@ fn remote_bash_command(script: &str) -> String {

fn remote_supervisor_command(binary: &str, directory: &str) -> String {
use super::ssh::sh_quote;
// An asynchronous `cd && nohup` list keeps the SSH output pipes open.
format!(
"cd {} || exit; nohup {} rental-supervise {} </dev/null > supervisor.log 2>&1 &",
sh_quote(directory),
let launch = sh_quote(&format!(
"nohup {} rental-supervise {} </dev/null > supervisor.log 2>&1 &",
sh_quote(binary),
sh_quote(&format!("{directory}/rental.json"))
));
// The foreground launcher establishes a session before Exec cleans up its original group.
format!(
"cd {} || exit; if command -v setsid >/dev/null 2>&1; then setsid /bin/sh -c {launch}; \
else python3 -c 'import os,sys; os.setsid(); os.execl(\"/bin/sh\", \"sh\", \"-c\", sys.argv[1])' {launch}; fi; exit $?",
sh_quote(directory),
)
}

Expand Down Expand Up @@ -245,32 +249,66 @@ pub async fn launch(
mod tests {
use super::*;
#[cfg(unix)]
#[tokio::test]
async fn remote_launch_returns_without_waiting_for_the_supervisor() {
#[test]
fn remote_launch_survives_exec_cleanup_without_waiting_for_the_supervisor() {
use std::os::unix::fs::PermissionsExt;

let temp = crate::local::git::TemporaryDirectory::new("orx-rental-detach").unwrap();
let bin = temp.path().join("bin");
std::fs::create_dir(&bin).unwrap();
let python = crate::local::shell_env::find("python3").unwrap();
std::os::unix::fs::symlink(python, bin.join("python3")).unwrap();
std::os::unix::fs::symlink("/usr/bin/nohup", bin.join("nohup")).unwrap();
let setsid = bin.join("setsid");
std::fs::write(
temp.path().join("rental-supervise"),
"touch started; sleep 2\n",
)
.unwrap();
let command = remote_supervisor_command("/bin/sh", temp.path().to_str().unwrap());
let output = tokio::time::timeout(
Duration::from_secs(1),
crate::process::tokio_command("/bin/sh")
.args(["-c", &command])
.output(),
)
.await
.unwrap()
.unwrap();
assert!(output.status.success());
tokio::time::timeout(Duration::from_secs(1), async {
while !temp.path().join("started").exists() {
tokio::time::sleep(Duration::from_millis(10)).await;
&setsid,
"#!/bin/sh\nexec python3 -c 'import os,sys; os.setsid(); os.execv(sys.argv[1],sys.argv[1:])' \"$@\"\n",
).unwrap();
std::fs::set_permissions(&setsid, std::fs::Permissions::from_mode(0o700)).unwrap();

for utility in [true, false] {
if !utility {
std::fs::remove_file(&setsid).unwrap();
}
})
.await
.unwrap();
let dir = temp.path().join(if utility {
"with setsid"
} else {
"without setsid"
});
std::fs::create_dir(&dir).unwrap();
std::fs::write(
dir.join("rental-supervise"),
"read -r value < \"$1\"; /bin/sleep 0.2; printf '%s' \"$value\" > survived\n",
)
.unwrap();
std::fs::write(dir.join("rental.json"), "detached\n").unwrap();

let command = remote_supervisor_command("/bin/sh", dir.to_str().unwrap());
let result = orx_host::exec::run(
crate::process::command("/bin/sh")
.args(["-c", &command])
.env("PATH", &bin),
&[],
Duration::from_secs(2),
None,
)
.unwrap();
assert_eq!(result.code, Some(0), "{result:?}");
assert!(!result.timed_out, "{result:?}");

let deadline = std::time::Instant::now() + Duration::from_secs(2);
while std::fs::read_to_string(dir.join("survived"))
.ok()
.as_deref()
!= Some("detached")
{
assert!(
std::time::Instant::now() < deadline,
"setsid available: {utility}"
);
std::thread::sleep(Duration::from_millis(10));
}
}
}
#[cfg(unix)]
#[test]
Expand Down
Loading