Skip to content

Commit

Permalink
feat(standalone-daemon): pass configuration with -c CLI option (#244)
Browse files Browse the repository at this point in the history
Although the option was present, the daemon did not actually read and
process the configuration file.

This commit introduces this feature, which allows loading extensions and
paves the way for nodes written in other programming languages.

* zenoh-flow-standalone-daemon/src/main.rs: read the configuration file
  pointed at by the provided path.

Signed-off-by: Julien Loudet <julien.loudet@zettascale.tech>
  • Loading branch information
J-Loudet authored Apr 9, 2024
1 parent f4bb728 commit 806e89f
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions zenoh-flow-standalone-daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,6 @@ async fn main() {
return;
}

let runtime_builder = match cli.configuration {
Some(path) => {
let (zenoh_flow_configuration, _) =
try_parse_from_file::<ZenohFlowConfiguration>(&path, Vars::default())
.unwrap_or_else(|e| {
panic!(
"Failed to parse a Zenoh-Flow Configuration from < {} >:\n{e:?}",
path.display()
)
});

Runtime::builder(zenoh_flow_configuration.name)
}
None => Runtime::builder(cli.name.unwrap()),
};

let zenoh_config = match cli.zenoh_configuration {
Some(path) => zenoh::prelude::Config::from_file(path.clone()).unwrap_or_else(|e| {
panic!(
Expand All @@ -90,15 +74,31 @@ async fn main() {
.unwrap_or_else(|e| panic!("Failed to open Zenoh session:\n{e:?}"))
.into_arc();

let runtime = runtime_builder
.session(zenoh_session)
.build()
.await
.expect("Failed to build the Zenoh-Flow Runtime");
let daemon = match cli.configuration {
Some(path) => {
let (zenoh_flow_configuration, _) =
try_parse_from_file::<ZenohFlowConfiguration>(&path, Vars::default())
.unwrap_or_else(|e| {
panic!(
"Failed to parse a Zenoh-Flow Configuration from < {} >:\n{e:?}",
path.display()
)
});

let daemon = Daemon::spawn(runtime)
Daemon::spawn_from_config(zenoh_session, zenoh_flow_configuration)
.await
.expect("Failed to spawn the Zenoh-Flow Daemon")
}
None => Daemon::spawn(
Runtime::builder(cli.name.unwrap())
.session(zenoh_session)
.build()
.await
.expect("Failed to build the Zenoh-Flow Runtime"),
)
.await
.expect("Failed to spawn the Zenoh-Flow Daemon");
.expect("Failed to spawn the Zenoh-Flow Daemon"),
};

async_std::task::spawn(async move {
let mut signals = Signals::new([SIGTERM, SIGINT, SIGQUIT])
Expand All @@ -112,8 +112,8 @@ async fn main() {
break;
}

_ => {
unreachable!()
signal => {
tracing::warn!("Ignoring signal ({signal})");
}
}
}
Expand Down

0 comments on commit 806e89f

Please sign in to comment.