fix: p logs silently returning no output
All checks were successful
CI / Check, test, lint (push) Successful in 36s
All checks were successful
CI / Check, test, lint (push) Successful in 36s
This commit is contained in:
@@ -7,11 +7,13 @@ pub fn execute(job_id: &str, follow: bool) -> Result<()> {
|
||||
let job = db::find(job_id)?.with_context(|| format!("job '{}' not found", job_id))?;
|
||||
|
||||
let worker = cfg.resolve_worker(Some(&job.worker))?;
|
||||
// No quotes around the path: ~ must be expanded by the remote shell,
|
||||
// and single-quoting it would prevent that. The UUID is [0-9a-f-] so
|
||||
// no quoting is needed for safety.
|
||||
let log = format!("~/.p/jobs/{}/output.log", job.id);
|
||||
|
||||
if follow {
|
||||
if job.status != JobStatus::Running {
|
||||
// Job is done — just cat the log, no point following.
|
||||
eprintln!(
|
||||
"note: job {} is no longer running, showing full output",
|
||||
job.short_id()
|
||||
@@ -19,7 +21,7 @@ pub fn execute(job_id: &str, follow: bool) -> Result<()> {
|
||||
print_log(worker, &log)?;
|
||||
} else {
|
||||
// Stream live output. Ctrl+C kills ssh; the job keeps running.
|
||||
ssh::run_output(worker, &format!("tail -n +1 -f '{}'", log))?;
|
||||
ssh::run_output(worker, &format!("tail -n +1 -f {}", log))?;
|
||||
}
|
||||
} else {
|
||||
print_log(worker, &log)?;
|
||||
@@ -31,10 +33,7 @@ pub fn execute(job_id: &str, follow: bool) -> Result<()> {
|
||||
fn print_log(worker: &crate::config::WorkerConfig, log: &str) -> Result<()> {
|
||||
let out = ssh::run_capture(
|
||||
worker,
|
||||
&format!(
|
||||
"cat '{}' 2>/dev/null || echo '(no output captured yet)'",
|
||||
log
|
||||
),
|
||||
&format!("cat {} 2>/dev/null || echo '(no output captured yet)'", log),
|
||||
)?;
|
||||
print!("{}", out);
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user