Skip to content
6 changes: 5 additions & 1 deletion docs/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,16 @@ Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name
|---|---|
| `orx up --remote-host` | Refused. The control channel is a Unix domain socket. |
| Restart after an update | There is no `exec`, so a restarting `orx up` starts a new process and exits. In a terminal the prompt comes back while the server keeps running in that console, where Ctrl+C still stops it; a supervisor sees the old process exit. |
| SSH connection reuse | Windows' OpenSSH cannot multiplex, so each status or log poll opens its own connection, and the Settings page uses the most recent preflight result instead of reporting a missing multiplexed master as a disconnection. Use a key held by an agent, or one without a passphrase. |
| SSH connection reuse | Windows' OpenSSH cannot multiplex. Each orx process instead keeps one batch SSH shell per target, shared by staging, launch, status and log commands. A detached supervisor opens its own shell and reuses it across polls. Use a key held by an agent, or one without a passphrase. The Settings page uses the most recent preflight result rather than checking for a multiplexed master. |
| The PATH guard | Not applied; it needs a POSIX shell startup file. |
| Data directory | Still `%USERPROFILE%\.local\share\openresearch`, not `%APPDATA%`. |
| Signing out or upgrading while the app runs | Windows ends the app at once, without stopping the agents it started or saving the last workspace state. |
| Starting the app while it is quitting | The new launch finds the old one still running and exits, so start it again once it has closed. |

On servers that rate-limit new SSH connections, connection timeouts are retried before any remote command is sent, with delays of 30, 60 and 120 seconds. A command whose connection drops after submission is not automatically replayed: it may already have launched a job. Separate launches and supervisors still have separate connections, so many concurrent runs can require a higher server limit.

Set `ORX_SSH_POLL_INTERVAL_SECS` before launching orx to change SSH supervisor status and log polling (for example, `60` for once a minute). Positive integer seconds are accepted; unset, zero or invalid values keep the defaults of five seconds for status and two seconds for logs. This also affects SSH-backed managed instances and Slurm log polling. A longer interval delays status updates and cancellation checks; it does not close the reused SSH connection.

## Releasing the app

`release-windows-app.yml` builds `OpenResearch-Setup.exe` from each release's
Expand Down
35 changes: 31 additions & 4 deletions src/commands/supervise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,13 @@ async fn cancel_modal(sandbox_id: &str, run_id: &str, cancel_sent: &mut bool) {
// it dead without an exit_code (ERROR) — so once cancel is sent we report the
// terminal state as `cancelled`.

fn ssh_poll_interval(value: Option<&str>, default: Duration) -> Duration {
value
.and_then(|value| value.parse::<std::num::NonZeroU64>().ok())
.map(|seconds| Duration::from_secs(seconds.get()))
.unwrap_or(default)
}

async fn run_ssh(
store: Store,
stored: crate::store::StoredRun,
Expand Down Expand Up @@ -670,6 +677,10 @@ async fn watch_ssh_job(
sandbox: Option<(&Credentials, &str)>,
) -> Result<RunStatus> {
let container = descriptor.ssh_container.clone();
let interval = ssh_poll_interval(
std::env::var("ORX_SSH_POLL_INTERVAL_SECS").ok().as_deref(),
POLL_INTERVAL,
);
let path = log_path(run_id);
let (done_tx, done_rx) = tokio::sync::watch::channel(false);
let (log_error_tx, log_error_rx) = tokio::sync::watch::channel(None);
Expand Down Expand Up @@ -747,7 +758,7 @@ async fn watch_ssh_job(
},
_ => {
missing_polls = 0;
tokio::time::sleep(POLL_INTERVAL).await;
tokio::time::sleep(interval).await;
continue;
}
},
Expand All @@ -756,7 +767,7 @@ async fn watch_ssh_job(
if job.message.as_deref() == Some(ssh::RUN_DIR_MISSING) {
missing_polls += 1;
if missing_polls < 3 {
tokio::time::sleep(POLL_INTERVAL).await;
tokio::time::sleep(interval).await;
continue;
}
} else {
Expand Down Expand Up @@ -815,7 +826,7 @@ async fn watch_ssh_job(
cancel_ssh(&target, &dir, container.as_ref(), run_id, &mut cancel_sent).await;
}

tokio::time::sleep(POLL_INTERVAL).await;
tokio::time::sleep(interval).await;
}
}

Expand All @@ -829,6 +840,10 @@ async fn tail_logs_ssh(
done: tokio::sync::watch::Receiver<bool>,
errors: Option<tokio::sync::watch::Sender<Option<String>>>,
) {
let interval = ssh_poll_interval(
std::env::var("ORX_SSH_POLL_INTERVAL_SECS").ok().as_deref(),
Duration::from_secs(2),
);
let mut log = match RunLog::open(&path) {
Ok(log) => log,
Err(err) => {
Expand Down Expand Up @@ -868,7 +883,7 @@ async fn tail_logs_ssh(
if draining && last_error.is_none() {
return;
}
tokio::time::sleep(Duration::from_secs(2)).await;
tokio::time::sleep(interval).await;
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
}
}

Expand Down Expand Up @@ -1644,6 +1659,18 @@ mod tests {
let _ = std::fs::remove_dir_all(dir);
}

#[test]
fn ssh_polling_accepts_positive_seconds_and_preserves_defaults() {
let default = Duration::from_secs(5);
assert_eq!(
ssh_poll_interval(Some("60"), default),
Duration::from_secs(60)
);
for value in [None, Some("0"), Some("-1"), Some("invalid")] {
assert_eq!(ssh_poll_interval(value, default), default);
}
}

#[test]
fn a_run_lock_is_held_only_while_its_supervisor_lives() {
let dir =
Expand Down
37 changes: 36 additions & 1 deletion src/jobs/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! `kubectl`), so auth is your `~/.ssh/config` + agent/keys — orx never reads a
//! key. On unix, connections are multiplexed (ControlMaster) so the many status/log
//! polls reuse one TCP session instead of a handshake apiece.
//! Win32-OpenSSH cannot, so on Windows background calls need an agent key or no passphrase.
//! Win32-OpenSSH cannot, so Windows reuses a single batch shell per target and process.
//!
//! The handle is a remote run directory `~/.orx/runs/<run_id>/` holding:
//! run.sh the launcher (exported env + snapshot-and-run payload)
Expand All @@ -17,6 +17,8 @@
mod container;
#[cfg(unix)]
mod prepared;
#[cfg(any(windows, test))]
mod session;
#[cfg(unix)]
mod sharing;
pub use container::{
Expand All @@ -26,9 +28,11 @@ pub use container::{
use std::collections::HashMap;
#[cfg(unix)]
use std::path::PathBuf;
#[cfg(not(windows))]
use std::process::Stdio;
use std::time::Duration;

#[cfg(not(windows))]
use tokio::process::Command;

use crate::error::{anyhow, Result};
Expand Down Expand Up @@ -548,6 +552,21 @@ async fn ssh_run_bytes(
target: &SshTarget,
remote_cmd: &str,
stdin: Option<&[u8]>,
) -> Result<String> {
#[cfg(windows)]
{
let input = stdin.unwrap_or_default();
return session::run(target, remote_cmd, &mut &input[..], input.len() as u64).await;
}
#[cfg(not(windows))]
ssh_run_bytes_once(target, remote_cmd, stdin).await
}

#[cfg(not(windows))]
async fn ssh_run_bytes_once(
target: &SshTarget,
remote_cmd: &str,
stdin: Option<&[u8]>,
) -> Result<String> {
prepare_control_dir()?;
#[cfg(unix)]
Expand Down Expand Up @@ -606,6 +625,22 @@ async fn ssh_run_file(
target: &SshTarget,
remote_cmd: &str,
source: &std::path::Path,
) -> Result<String> {
#[cfg(windows)]
{
let mut file = tokio::fs::File::open(source).await?;
let size = file.metadata().await?.len();
return session::run(target, remote_cmd, &mut file, size).await;
}
#[cfg(not(windows))]
ssh_run_file_once(target, remote_cmd, source).await
}

#[cfg(not(windows))]
async fn ssh_run_file_once(
target: &SshTarget,
remote_cmd: &str,
source: &std::path::Path,
) -> Result<String> {
prepare_control_dir()?;
#[cfg(unix)]
Expand Down
Loading
Loading