Skip to content

Commit 570027f

Browse files
sergeymatovFredi-raspall
authored andcommitted
feat(mgmt): add grpc server addr option
Signed-off-by: Sergey Matov <[email protected]>
1 parent 886f244 commit 570027f

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

dataplane/src/args.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(unused)]
55

66
pub(crate) use clap::Parser;
7+
use std::net::SocketAddr;
78
use tracing::debug;
89

910
#[derive(Parser)]
@@ -30,7 +31,16 @@ pub(crate) struct CmdArgs {
3031
driver: Option<String>,
3132
#[arg(long, value_name = "name of kernel interface")]
3233
interface: Vec<String>,
34+
35+
// gRPC server address
36+
#[arg(
37+
long,
38+
value_name = "gRPC server address",
39+
default_value = "[::1]:50051"
40+
)]
41+
grpc_address: String,
3342
}
43+
3444
impl CmdArgs {
3545
pub fn get_driver_name(&self) -> &str {
3646
match &self.driver {
@@ -92,4 +102,15 @@ impl CmdArgs {
92102

93103
out
94104
}
105+
106+
/// Get the gRPC server address
107+
pub fn get_grpc_address(&self) -> SocketAddr {
108+
match self.grpc_address.parse() {
109+
Ok(addr) => addr,
110+
Err(e) => {
111+
eprintln!("Error: Invalid gRPC address '{}': {}", self.grpc_address, e);
112+
panic!("Process receives unexpected gRPC address. Aborting...");
113+
}
114+
}
115+
}
95116
}

dataplane/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ fn main() {
6161
/* parse cmd line args */
6262
let args = CmdArgs::parse();
6363

64-
let grpc_address = "[::1]:50051".parse().expect("Bad grpc address");
65-
66-
if let Err(e) = start_mgmt(grpc_address) {
64+
// Get the gRPC address from command line args
65+
let grpc_addr = args.get_grpc_address();
66+
if let Err(e) = start_mgmt(grpc_addr) {
6767
error!("Failed to start management service: {e}");
68-
std::process::exit(0);
68+
panic!("Management service failed to start. Aborting...");
6969
}
7070

7171
debug!("Starting pipeline....");
@@ -82,7 +82,7 @@ fn main() {
8282
}
8383
other => {
8484
error!("Unknown driver '{other}'. Aborting...");
85-
std::process::exit(0);
85+
panic!("Packet processing pipeline failed to start. Aborting...");
8686
}
8787
}
8888

0 commit comments

Comments
 (0)