fix: create remote directories before syncing
All checks were successful
CI / Check, test, lint (push) Successful in 30s
All checks were successful
CI / Check, test, lint (push) Successful in 30s
This commit is contained in:
@@ -34,7 +34,23 @@ pub fn execute(worker_name: Option<&str>, cmd: Vec<String>, no_sync: bool) -> Re
|
||||
.context("directory sync failed")?;
|
||||
}
|
||||
|
||||
// ── 2. Save local job record ──────────────────────────────────────────────
|
||||
// ── 1. Create remote directories ─────────────────────────────────────────
|
||||
// Must happen before sync so rsync has a destination to write into.
|
||||
|
||||
ssh::run_capture(&worker, &format!("mkdir -p {} {}", job_dir, work_dir))
|
||||
.context("failed to create remote directories")?;
|
||||
|
||||
// ── 2. Sync directory ─────────────────────────────────────────────────────
|
||||
|
||||
if no_sync {
|
||||
eprintln!("Skipping sync (--no-sync).");
|
||||
} else {
|
||||
eprintln!("Syncing to {}...", worker.name);
|
||||
sync::push_dir(&worker, &std::env::current_dir()?, &work_dir)
|
||||
.context("directory sync failed")?;
|
||||
}
|
||||
|
||||
// ── 3. Save local job record ──────────────────────────────────────────────
|
||||
// Written before touching the remote so that `p ls` shows the job as
|
||||
// running even if we lose the connection immediately after.
|
||||
|
||||
@@ -50,21 +66,19 @@ pub fn execute(worker_name: Option<&str>, cmd: Vec<String>, no_sync: bool) -> Re
|
||||
};
|
||||
db::save(&job)?;
|
||||
|
||||
// ── 3. Write files and start the job on the worker ────────────────────────
|
||||
// ── 4. Write files and start the job on the worker ────────────────────────
|
||||
|
||||
let cmd_b64 = B64.encode(&cmd_str);
|
||||
let run_sh = build_run_sh(&session, &job_dir, &work_dir, &worker.name);
|
||||
let run_sh_b64 = B64.encode(&run_sh);
|
||||
|
||||
let setup = format!(
|
||||
"mkdir -p {job_dir} {work_dir} && \
|
||||
printf '%s' '{cmd_b64}' > {job_dir}/cmd && \
|
||||
"printf '%s' '{cmd_b64}' > {job_dir}/cmd && \
|
||||
printf '%s' '{run_sh_b64}' | base64 -d > {job_dir}/run.sh && \
|
||||
chmod +x {job_dir}/run.sh && \
|
||||
date +%s > {job_dir}/started_at && \
|
||||
tmux new-session -d -s '{session}' {job_dir}/run.sh",
|
||||
job_dir = job_dir,
|
||||
work_dir = work_dir,
|
||||
cmd_b64 = cmd_b64,
|
||||
run_sh_b64 = run_sh_b64,
|
||||
session = session,
|
||||
|
||||
Reference in New Issue
Block a user