Browse Source

CLI check wether dora-runtime is running

tags/v0.0.0-test-pr-120
Philipp Oppermann 3 years ago
parent
commit
559875a577
Failed to extract signature
4 changed files with 70 additions and 16 deletions
  1. +8
    -4
      Cargo.lock
  2. +3
    -0
      binaries/cli/Cargo.toml
  3. +51
    -9
      binaries/cli/src/check.rs
  4. +8
    -3
      binaries/cli/src/main.rs

+ 8
- 4
Cargo.lock View File

@@ -885,12 +885,16 @@ dependencies = [
name = "dora-cli"
version = "0.1.0"
dependencies = [
"atty",
"clap 4.0.3",
"communication-layer-pub-sub",
"dora-core",
"eyre",
"serde_json",
"serde_yaml 0.9.11",
"tempfile",
"termcolor",
"uuid 1.2.1",
"webbrowser",
"zenoh",
]
@@ -990,7 +994,7 @@ dependencies = [
"tokio",
"tracing",
"tracing-subscriber",
"uuid 1.1.2",
"uuid 1.2.1",
]

[[package]]
@@ -4040,7 +4044,7 @@ dependencies = [
"lazy_static",
"log",
"serde",
"uuid 1.1.2",
"uuid 1.2.1",
]

[[package]]
@@ -4157,9 +4161,9 @@ dependencies = [

[[package]]
name = "uuid"
version = "1.1.2"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f"
checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83"
dependencies = [
"getrandom",
]


+ 3
- 0
binaries/cli/Cargo.toml View File

@@ -18,3 +18,6 @@ tempfile = "3.3.0"
webbrowser = "0.8.0"
zenoh = { git = "https://github.com/eclipse-zenoh/zenoh.git" }
serde_json = "1.0.86"
termcolor = "1.1.3"
atty = "0.2.14"
uuid = { version = "1.2.1", features = ["v4"] }

+ 51
- 9
binaries/cli/src/check.rs View File

@@ -1,14 +1,52 @@
use crate::graph::read_descriptor;
use crate::{graph::read_descriptor, zenoh_control_session};
use dora_core::{
adjust_shared_library_path,
config::{InputMapping, UserInputMapping},
descriptor::{self, source_is_url, CoreNodeKind, OperatorSource},
topics::ZENOH_CONTROL_LIST,
};
use eyre::{bail, eyre, Context};
use std::{env::consts::EXE_EXTENSION, path::Path};
use std::{env::consts::EXE_EXTENSION, io::Write, path::Path};
use termcolor::{Color, ColorChoice, ColorSpec, WriteColor};
use zenoh::{prelude::Receiver, sync::ZFuture};

pub fn check(dataflow_path: &Path, runtime: &Path) -> eyre::Result<()> {
let runtime = runtime.with_extension(EXE_EXTENSION);
pub fn check_environment() -> eyre::Result<()> {
let mut control_session = None;

let color_choice = if atty::is(atty::Stream::Stdout) {
ColorChoice::Auto
} else {
ColorChoice::Never
};
let mut stdout = termcolor::StandardStream::stdout(color_choice);

// check whether coordinator is running
let reply_receiver = zenoh_control_session(&mut control_session)?
.get(ZENOH_CONTROL_LIST)
.wait()
.map_err(|err| eyre!(err))
.wrap_err("failed to create publisher for list message")?;
write!(stdout, "Dora Coordinator: ")?;
match reply_receiver.recv() {
Ok(_) => {
let _ = stdout.set_color(ColorSpec::new().set_fg(Some(Color::Green)));
writeln!(stdout, "ok")?;
}
Err(_) => {
let _ = stdout.set_color(ColorSpec::new().set_fg(Some(Color::Red)));
writeln!(stdout, "not running")?;
}
}
let _ = stdout.reset();

// check whether roudi is running

// TODO, blocked on https://github.com/eclipse-iceoryx/iceoryx-rs/issues/62

Ok(())
}

pub fn check_dataflow(dataflow_path: &Path, runtime: Option<&Path>) -> eyre::Result<()> {
let descriptor = read_descriptor(dataflow_path).wrap_err_with(|| {
format!(
"failed to read dataflow descriptor at {}",
@@ -27,12 +65,16 @@ pub fn check(dataflow_path: &Path, runtime: &Path) -> eyre::Result<()> {
if nodes
.iter()
.any(|n| matches!(n.kind, CoreNodeKind::Runtime(_)))
&& !runtime.is_file()
{
bail!(
"There is no runtime at {}, or it is not a file",
runtime.display()
);
let runtime = runtime
.unwrap_or_else(|| Path::new("dora-runtime"))
.with_extension(EXE_EXTENSION);
if !runtime.is_file() {
bail!(
"There is no runtime at {}, or it is not a file",
runtime.display()
);
}
}

// check that nodes and operators exist


+ 8
- 3
binaries/cli/src/main.rs View File

@@ -26,8 +26,10 @@ struct Args {
#[derive(Debug, clap::Subcommand)]
enum Command {
Check {
dataflow: PathBuf,
runtime_path: PathBuf,
#[clap(long)]
dataflow: Option<PathBuf>,
#[clap(long)]
runtime_path: Option<PathBuf>,
},
Graph {
dataflow: PathBuf,
@@ -93,7 +95,10 @@ fn main() -> eyre::Result<()> {
Command::Check {
dataflow,
runtime_path,
} => check::check(&dataflow, &runtime_path)?,
} => match dataflow {
Some(dataflow) => check::check_dataflow(&dataflow, runtime_path.as_deref())?,
None => check::check_environment()?,
},
Command::Graph {
dataflow,
mermaid,


Loading…
Cancel
Save