cln-grpc: Do not start unless a grpc-port is specified

For now we don't want to autostart.

Suggested-by: Rusty Russell <@rustyrussell>
This commit is contained in:
Christian Decker
2022-03-23 11:50:36 +01:00
committed by Rusty Russell
parent bf7ad86ef2
commit 09ee28cb51
3 changed files with 22 additions and 6 deletions

View File

@@ -31,13 +31,17 @@ async fn main() -> Result<()> {
let plugin = Builder::new(state.clone(), tokio::io::stdin(), tokio::io::stdout())
.option(options::ConfigOption::new(
"grpc-port",
options::Value::Integer(50051),
options::Value::Integer(-1),
"Which port should the grpc plugin listen for incoming connections?",
))
.start()
.await?;
let bind_port = match plugin.option("grpc-port") {
Some(options::Value::Integer(-1)) => {
log::info!("`grpc-port` option is not configured, exiting.");
return Ok(());
}
Some(options::Value::Integer(i)) => i,
None => return Err(anyhow!("Missing 'grpc-port' option")),
Some(o) => return Err(anyhow!("grpc-port is not a valid integer: {:?}", o)),