use inherit to print output.
This commit is contained in:
parent
140e9ebe1c
commit
09b4d36a72
21
src/retry.rs
Normal file
21
src/retry.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
use std::process::{Command, Stdio};
|
||||||
|
use std::thread;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
pub fn retry(cmd: &str, cmd_args: &[String]) {
|
||||||
|
loop {
|
||||||
|
let mut child = Command::new(cmd)
|
||||||
|
.args(cmd_args)
|
||||||
|
.stdout(Stdio::inherit())
|
||||||
|
.stderr(Stdio::inherit())
|
||||||
|
.spawn()
|
||||||
|
.expect("Failed to spawn command.");
|
||||||
|
|
||||||
|
if child.wait().unwrap().success() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Error, wait 1s for retry.");
|
||||||
|
thread::sleep(Duration::from_secs(1));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user