cln-grpc: Do not exit if grpc-port is not set

Exiting doesn't mesh well with builtin plugins, so just sit there and
do nothing

Changelog-None
This commit is contained in:
Christian Decker
2022-04-07 17:59:37 +02:00
committed by Rusty Russell
parent 9a8bc777e5
commit 9826402c99
2 changed files with 12 additions and 9 deletions

View File

@@ -40,12 +40,14 @@ async fn main() -> Result<()> {
let bind_port = match plugin.option("grpc-port") { let bind_port = match plugin.option("grpc-port") {
Some(options::Value::Integer(-1)) => { Some(options::Value::Integer(-1)) => {
log::info!("`grpc-port` option is not configured, exiting."); log::info!("`grpc-port` option is not configured, exiting.");
return Ok(()); None
} }
Some(options::Value::Integer(i)) => i, Some(options::Value::Integer(i)) => Some(i),
None => return Err(anyhow!("Missing 'grpc-port' option")), None => return Err(anyhow!("Missing 'grpc-port' option")),
Some(o) => return Err(anyhow!("grpc-port is not a valid integer: {:?}", o)), Some(o) => return Err(anyhow!("grpc-port is not a valid integer: {:?}", o)),
}; };
if let Some(bind_port) = bind_port {
let bind_addr: SocketAddr = format!("0.0.0.0:{}", bind_port).parse().unwrap(); let bind_addr: SocketAddr = format!("0.0.0.0:{}", bind_port).parse().unwrap();
tokio::spawn(async move { tokio::spawn(async move {
@@ -53,6 +55,7 @@ async fn main() -> Result<()> {
warn!("Error running the grpc interface: {}", e); warn!("Error running the grpc interface: {}", e);
} }
}); });
}
plugin.join().await plugin.join().await
} }

View File

@@ -176,7 +176,7 @@ def test_grpc_no_auto_start(node_factory):
"plugin": str(bin_path), "plugin": str(bin_path),
}) })
wait_for(lambda: [p for p in l1.rpc.plugin('list')['plugins'] if 'cln-grpc' in p['name']] == []) l1.daemon.logsearch_start = 0
assert l1.daemon.is_in_log(r'plugin-cln-grpc: Killing plugin: exited during normal operation') assert l1.daemon.is_in_log(r'plugin-cln-grpc: Killing plugin: exited during normal operation')