cli: Add PID to `node start` message
We also use a spinner in case it takes longer.
This commit is contained in:
parent
0123433f81
commit
a84555955d
|
|
@ -50,21 +50,26 @@ pub fn start(
|
||||||
.create(true)
|
.create(true)
|
||||||
.open(profile.home.node().join("node.log"))?;
|
.open(profile.home.node().join("node.log"))?;
|
||||||
|
|
||||||
process::Command::new("radicle-node")
|
let child = process::Command::new("radicle-node")
|
||||||
.args(options)
|
.args(options)
|
||||||
.envs(envs)
|
.envs(envs)
|
||||||
.stdin(process::Stdio::null())
|
.stdin(process::Stdio::null())
|
||||||
.stdout(process::Stdio::from(log))
|
.stdout(process::Stdio::from(log))
|
||||||
.stderr(process::Stdio::null())
|
.stderr(process::Stdio::null())
|
||||||
.spawn()?;
|
.spawn()?;
|
||||||
|
let pid = term::format::parens(term::format::dim(child.id()));
|
||||||
|
|
||||||
if verbose {
|
if verbose {
|
||||||
logs(0, Some(time::Duration::from_secs(1)), profile)?;
|
logs(0, Some(time::Duration::from_secs(1)), profile)?;
|
||||||
} else {
|
} else {
|
||||||
let started = time::Instant::now();
|
let started = time::Instant::now();
|
||||||
|
let mut spinner = term::spinner(format!("Node starting.. {pid}"));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if node.is_running() {
|
if node.is_running() {
|
||||||
term::success!("Node started");
|
spinner.message(format!("Node started {pid}"));
|
||||||
|
spinner.finish();
|
||||||
|
|
||||||
term::print(term::format::dim(
|
term::print(term::format::dim(
|
||||||
"To stay in sync with the network, leave the node running in the background.",
|
"To stay in sync with the network, leave the node running in the background.",
|
||||||
));
|
));
|
||||||
|
|
@ -74,7 +79,6 @@ pub fn start(
|
||||||
term::format::command("rad node --help"),
|
term::format::command("rad node --help"),
|
||||||
term::format::dim("."),
|
term::format::dim("."),
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else if started.elapsed() >= NODE_START_TIMEOUT {
|
} else if started.elapsed() >= NODE_START_TIMEOUT {
|
||||||
anyhow::bail!("node failed to start. Try running in verbose mode with `rad node start --verbose`");
|
anyhow::bail!("node failed to start. Try running in verbose mode with `rad node start --verbose`");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue