debug: add warn logs to curl thread, fix temp file uniqueness

This commit is contained in:
M1 2026-03-18 13:17:11 +04:00
parent 556729b881
commit cb8d0f81b1
1 changed files with 5 additions and 1 deletions

View File

@ -190,7 +190,8 @@ async fn run_curl(
use std::process::Stdio;
// Write output to a temp file so we just wait for the process to exit
let tmp = format!("/tmp/pingql-curl-{}.txt", std::process::id());
let tmp = format!("/tmp/pingql-curl-{}-{}.txt", std::process::id(),
std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap_or_default().subsec_nanos());
let mut args: Vec<String> = vec![
"--silent".into(),
@ -224,13 +225,16 @@ async fn run_curl(
let tmp_owned = tmp.clone();
let (tx, rx) = tokio::sync::oneshot::channel::<(std::io::Result<std::process::ExitStatus>, Vec<u8>)>();
let url_log = url.to_string();
std::thread::spawn(move || {
tracing::warn!("curl thread starting for {url_log}");
let status = std::process::Command::new("curl")
.args(&args_owned)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status();
tracing::warn!("curl thread done for {url_log}: {:?}", status);
let output = std::fs::read(&tmp_owned).unwrap_or_default();
let _ = std::fs::remove_file(&tmp_owned);
let _ = tx.send((status, output));