Unverified Commit e75bcf67 authored by Graham King's avatar Graham King Committed by GitHub
Browse files

fix(dynamo-run): Run without etcd/nats, HTTP port to 8000 (#4555)


Signed-off-by: default avatarGraham King <grahamk@nvidia.com>
parent f0ca16f0
......@@ -31,7 +31,7 @@ pub struct Flags {
/// HTTP port. `in=http` only
/// If tls_cert_path and tls_key_path are provided, this will be TLS/HTTPS.
#[arg(long, default_value = "8080")]
#[arg(long, default_value = "8000")]
pub http_port: u16,
/// TLS certificate file
......
......@@ -77,17 +77,23 @@ pub async fn run(
if let Input::Endpoint(path) = &in_opt {
builder.endpoint_id(Some(path.parse().with_context(|| path.clone())?));
}
let selected_store: KeyValueStoreSelect = flags.store_kv.parse()?;
let request_plane: RequestPlaneMode = flags.request_plane.parse()?;
let dst_config = DistributedConfig {
store_backend: selected_store,
// We only need NATS here to monitor it's metrics, so only if it's our request plane.
nats_config: if request_plane.is_nats() {
Some(nats::ClientOptions::default())
} else {
None
},
request_plane,
let dst_config = if is_process_local(&in_opt, &out_opt) {
// We are both the frontend and backend, no networking
DistributedConfig::process_local()
} else {
// Normal case
let selected_store: KeyValueStoreSelect = flags.store_kv.parse()?;
let request_plane: RequestPlaneMode = flags.request_plane.parse()?;
DistributedConfig {
store_backend: selected_store,
// We only need NATS here to monitor it's metrics, so only if it's our request plane.
nats_config: if request_plane.is_nats() {
Some(nats::ClientOptions::default())
} else {
None
},
request_plane,
}
};
let distributed_runtime = DistributedRuntime::new(runtime.clone(), dst_config).await?;
let local_model = builder.build().await?;
......@@ -117,6 +123,18 @@ pub async fn run(
Ok(())
}
pub fn is_in_dynamic(in_opt: &Input) -> bool {
matches!(in_opt, Input::Endpoint(_))
}
pub fn is_out_dynamic(out_opt: &Option<Output>) -> bool {
matches!(out_opt, Some(Output::Auto))
}
fn is_process_local(in_opt: &Input, out_opt: &Option<Output>) -> bool {
!is_in_dynamic(in_opt) && !is_out_dynamic(out_opt)
}
/// Create the engine matching `out_opt`
/// Note validation happens in Flags::validate. In here assume everything is going to work.
async fn engine_for(
......
......@@ -127,17 +127,9 @@ async fn wrapper(runtime: dynamo_runtime::Runtime) -> anyhow::Result<()> {
.chain(env::args().skip(non_flag_params)),
)?;
if is_in_dynamic(&in_opt) && is_out_dynamic(&out_opt) {
if dynamo_run::is_in_dynamic(&in_opt) && dynamo_run::is_out_dynamic(&out_opt) {
anyhow::bail!("Cannot use endpoint for both in and out");
}
dynamo_run::run(runtime, in_opt, out_opt, flags).await
}
fn is_in_dynamic(in_opt: &Input) -> bool {
matches!(in_opt, Input::Endpoint(_))
}
fn is_out_dynamic(out_opt: &Option<Output>) -> bool {
matches!(out_opt, Some(Output::Auto))
}
......@@ -447,6 +447,18 @@ impl DistributedConfig {
request_plane,
}
}
/// A DistributedConfig that isn't distributed, for when the frontend and backend are in the
/// same process.
pub fn process_local() -> DistributedConfig {
DistributedConfig {
store_backend: KeyValueStoreSelect::Memory,
nats_config: None,
// This won't be used in process local, so we likely need a "none" option to
// communicate that and avoid opening the ports.
request_plane: RequestPlaneMode::Tcp,
}
}
}
/// Request plane transport mode configuration
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment