Browse Source

Allow configuring the `dora up` behavior through a `dora-config.yml` file

tags/v0.1.0
Philipp Oppermann 3 years ago
parent
commit
ef4046165e
Failed to extract signature
4 changed files with 46 additions and 5 deletions
  1. +1
    -0
      Cargo.lock
  2. +1
    -0
      binaries/cli/Cargo.toml
  3. +8
    -1
      binaries/cli/src/main.rs
  4. +36
    -4
      binaries/cli/src/up.rs

+ 1
- 0
Cargo.lock View File

@@ -878,6 +878,7 @@ dependencies = [
"clap 4.0.3",
"dora-core",
"eyre",
"serde",
"serde_json",
"serde_yaml 0.9.11",
"sysinfo 0.26.6",


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

@@ -13,6 +13,7 @@ path = "src/main.rs"
clap = { version = "4.0.3", features = ["derive"] }
eyre = "0.6.8"
dora-core = { path = "../../libraries/core" }
serde = { version = "1.0.136", features = ["derive"] }
serde_yaml = "0.9.11"
tempfile = "3.3.0"
webbrowser = "0.8.0"


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

@@ -47,6 +47,8 @@ enum Command {
},
Dashboard,
Up {
#[clap(long)]
config: Option<PathBuf>,
#[clap(long)]
roudi_path: Option<PathBuf>,
#[clap(long)]
@@ -118,9 +120,14 @@ fn main() -> eyre::Result<()> {
Command::New { args } => template::create(args)?,
Command::Dashboard => todo!(),
Command::Up {
config,
roudi_path,
coordinator_path,
} => up::up(roudi_path.as_deref(), coordinator_path.as_deref())?,
} => up::up(
config.as_deref(),
roudi_path.as_deref(),
coordinator_path.as_deref(),
)?,
Command::Start { dataflow } => start_dataflow(dataflow, &mut session)?,
Command::List => list(&mut session)?,
Command::Stop { uuid } => stop_dataflow(uuid, &mut session)?,


+ 36
- 4
binaries/cli/src/up.rs View File

@@ -1,17 +1,49 @@
use crate::{check::coordinator_running, zenoh_control_session};
use dora_core::topics::ZENOH_CONTROL_DESTROY;
use eyre::{bail, eyre, Context};
use std::{path::Path, process::Command, sync::Arc};
use std::{fs, path::Path, process::Command, sync::Arc};
use sysinfo::{ProcessExt, SystemExt};
use zenoh::{prelude::Receiver, sync::ZFuture};

pub(crate) fn up(roudi: Option<&Path>, coordinator: Option<&Path>) -> eyre::Result<()> {
#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct UpConfig {
iceoryx: bool,
}

impl Default for UpConfig {
fn default() -> Self {
Self { iceoryx: true }
}
}

pub(crate) fn up(
config_path: Option<&Path>,
roudi: Option<&Path>,
coordinator: Option<&Path>,
) -> eyre::Result<()> {
let config = {
let path =
config_path.or_else(|| Some(Path::new("dora-config.yml")).filter(|p| p.exists()));
match path {
Some(path) => {
let raw = fs::read_to_string(path)
.with_context(|| format!("failed to read `{}`", path.display()))?;
serde_yaml::from_str(&raw)
.with_context(|| format!("failed to parse `{}`", path.display()))?
}
None => Default::default(),
}
};
let UpConfig { iceoryx } = config;

if !coordinator_running()? {
start_coordinator(coordinator).wrap_err("failed to start dora-coordinator")?;
}

// try to start roudi
start_roudi(roudi).wrap_err("failed to start iceoryx roudi daemon")?;
if iceoryx {
// try to start roudi
start_roudi(roudi).wrap_err("failed to start iceoryx roudi daemon")?;
}

Ok(())
}


Loading…
Cancel
Save