Igneum Miner jobs: the remaining helpers by absolute path too (curl, nvidia-smi, tar, powershell, taskkill, bash, nohup through platform::tool)
d5398f3 switched only wsl: BSD sed dropped the alternation. Now every Command::new in src/jobrun.rs goes
through platform::tool (R4.3.3).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
d5398f3ed6
commit
b49d3ee358
1 changed files with 14 additions and 14 deletions
|
|
@ -551,7 +551,7 @@ fn upload_file(shared: &Arc<Shared>, job: &Job, path: &Path, label_prefix: &str)
|
|||
// ---- fetching the jobs file and probing requirements -----------------------------------------------------------------
|
||||
|
||||
fn curl(args: &[&str], limit: Duration) -> Result<(), String> {
|
||||
let mut c = Command::new("curl");
|
||||
let mut c = Command::new(crate::platform::tool("curl"));
|
||||
c.args(args);
|
||||
let (code, out) = run_capture(&mut c, limit);
|
||||
let t = out.trim();
|
||||
|
|
@ -576,7 +576,7 @@ fn fetch_jobs(url: &str, dir: &Path) -> Result<jobs::JobsFile, String> {
|
|||
/// Does this machine meet a requirement? Probed on the fetch thread, once per poll.
|
||||
fn probe(req: &str) -> bool {
|
||||
match req {
|
||||
"nvidia" => run_capture(Command::new("nvidia-smi").arg("-L"), Duration::from_secs(20)).0 == Some(0),
|
||||
"nvidia" => run_capture(Command::new(crate::platform::tool("nvidia-smi")).arg("-L"), Duration::from_secs(20)).0 == Some(0),
|
||||
"wsl" => cfg!(windows) && run_capture(Command::new(crate::platform::tool("wsl")).arg("--status"), Duration::from_secs(30)).0 == Some(0),
|
||||
"wsl-prover" => {
|
||||
cfg!(windows) && run_capture(Command::new(crate::platform::tool("wsl")).args(["-d", DEFAULT_DISTRO, "--", "bash", "-lc", "command -v cargo && ls ~/.sp1 && ls ~/igneum-prove"]), Duration::from_secs(90)).0 == Some(0)
|
||||
|
|
@ -705,7 +705,7 @@ fn run_streamed(cmd: &mut Command, sink: &Sink, ctl: &Ctl, limit: Duration, shar
|
|||
fn kill_tree(pid: u32) {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let mut c = Command::new("taskkill");
|
||||
let mut c = Command::new(crate::platform::tool("taskkill"));
|
||||
c.args(["/T", "/F", "/PID", &pid.to_string()]);
|
||||
crate::platform::quiet(&mut c);
|
||||
let _ = c.output();
|
||||
|
|
@ -757,14 +757,14 @@ fn fetch_file(url: &str, final_path: &Path, sha256: &str, size: Option<u64>, sin
|
|||
/// tar -xf (bsdtar on Windows 10 1803+ and macOS reads zip); PowerShell Expand-Archive as the Windows fallback.
|
||||
fn extract(archive: &Path, into: &Path, sink: &Sink) -> Result<(), String> {
|
||||
let _ = std::fs::create_dir_all(into);
|
||||
let (code, out) = run_capture(Command::new("tar").args(["-xf", &archive.display().to_string(), "-C", &into.display().to_string()]), Duration::from_secs(600));
|
||||
let (code, out) = run_capture(Command::new(crate::platform::tool("tar")).args(["-xf", &archive.display().to_string(), "-C", &into.display().to_string()]), Duration::from_secs(600));
|
||||
if code == Some(0) {
|
||||
sink.line(&format!("extracted {} into {}", archive.display(), into.display()));
|
||||
return Ok(());
|
||||
}
|
||||
if cfg!(windows) {
|
||||
let script = format!("Expand-Archive -LiteralPath '{}' -DestinationPath '{}' -Force", archive.display().to_string().replace('\'', "''"), into.display().to_string().replace('\'', "''"));
|
||||
let (c2, o2) = run_capture(Command::new("powershell").args(["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", &script]), Duration::from_secs(600));
|
||||
let (c2, o2) = run_capture(Command::new(crate::platform::tool("powershell")).args(["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", &script]), Duration::from_secs(600));
|
||||
if c2 == Some(0) {
|
||||
sink.line(&format!("extracted {} into {} (Expand-Archive)", archive.display(), into.display()));
|
||||
return Ok(());
|
||||
|
|
@ -823,13 +823,13 @@ fn run_script(shared: &Arc<Shared>, job: &Job, sink: &Sink, jobs_dir: &Path, dat
|
|||
let _ = std::fs::remove_file(&out_file);
|
||||
let inner = format!("-NoProfile -ExecutionPolicy Bypass -File \"{}\"", wrapper.display());
|
||||
let ps = format!("$p = Start-Process -FilePath powershell.exe -ArgumentList '{}' -Verb RunAs -Wait -WindowStyle Hidden -PassThru; exit $p.ExitCode", inner.replace('\'', "''"));
|
||||
cmd = Command::new("powershell");
|
||||
cmd = Command::new(crate::platform::tool("powershell"));
|
||||
cmd.args(["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", &ps]);
|
||||
} else if shell == "powershell" {
|
||||
cmd = Command::new("powershell");
|
||||
cmd = Command::new(crate::platform::tool("powershell"));
|
||||
cmd.args(["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", &script.display().to_string()]);
|
||||
} else {
|
||||
cmd = Command::new("bash");
|
||||
cmd = Command::new(crate::platform::tool("bash"));
|
||||
cmd.arg(&script);
|
||||
}
|
||||
cmd.current_dir(&dir);
|
||||
|
|
@ -923,11 +923,11 @@ fn run_collect(shared: &Arc<Shared>, job: &Job, sink: &Sink, data_root: &Path, c
|
|||
if !command.trim().is_empty() {
|
||||
sink.stage(&format!("running: {}", short(&command, 120)));
|
||||
let mut cmd = if cfg!(windows) {
|
||||
let mut c = Command::new("powershell");
|
||||
let mut c = Command::new(crate::platform::tool("powershell"));
|
||||
c.args(["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", &command]);
|
||||
c
|
||||
} else {
|
||||
let mut c = Command::new("bash");
|
||||
let mut c = Command::new(crate::platform::tool("bash"));
|
||||
c.args(["-lc", &command]);
|
||||
c
|
||||
};
|
||||
|
|
@ -943,7 +943,7 @@ fn run_collect(shared: &Arc<Shared>, job: &Job, sink: &Sink, data_root: &Path, c
|
|||
// ---- kind: shard-benchmark ----------------------------------------------------------------------------------------------
|
||||
|
||||
fn gpu_utilisation() -> Option<Vec<f64>> {
|
||||
let (code, out) = run_capture(Command::new("nvidia-smi").args(["--query-gpu=utilization.gpu", "--format=csv,noheader,nounits"]), Duration::from_secs(15));
|
||||
let (code, out) = run_capture(Command::new(crate::platform::tool("nvidia-smi")).args(["--query-gpu=utilization.gpu", "--format=csv,noheader,nounits"]), Duration::from_secs(15));
|
||||
if code != Some(0) {
|
||||
return None;
|
||||
}
|
||||
|
|
@ -1065,7 +1065,7 @@ fn spawn_relaunch_helper(shared: &Arc<Shared>) -> Result<(), String> {
|
|||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let b = crate::platform::bundle_path().ok_or("not running from Igneum Miner.app")?;
|
||||
c = Command::new("nohup");
|
||||
c = Command::new(crate::platform::tool("nohup"));
|
||||
c.args(["bash", "-c", &format!("sleep 8; open -n '{}'", b.display().to_string().replace('\'', "'\\''"))]);
|
||||
}
|
||||
#[cfg(windows)]
|
||||
|
|
@ -1073,13 +1073,13 @@ fn spawn_relaunch_helper(shared: &Arc<Shared>) -> Result<(), String> {
|
|||
let dir = std::env::current_exe().ok().and_then(|p| p.parent().map(|d| d.to_path_buf())).ok_or("cannot find the install folder")?;
|
||||
let exe = dir.join("igneum-app.exe");
|
||||
let ps = format!("Start-Sleep 8; Start-Process -FilePath '{}' -ArgumentList '--launch' -WorkingDirectory '{}'", exe.display().to_string().replace('\'', "''"), dir.display().to_string().replace('\'', "''"));
|
||||
c = Command::new("powershell");
|
||||
c = Command::new(crate::platform::tool("powershell"));
|
||||
c.args(["-NoProfile", "-ExecutionPolicy", "Bypass", "-WindowStyle", "Hidden", "-Command", &ps]);
|
||||
}
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
{
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
c = Command::new("nohup");
|
||||
c = Command::new(crate::platform::tool("nohup"));
|
||||
c.args(["bash", "-c", &format!("sleep 8; '{}' --no-open &", exe.display())]);
|
||||
}
|
||||
c.stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());
|
||||
|
|
|
|||
Loading…
Reference in a new issue