mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 08:04:26 +01:00
cln-grpc: Add midstate between configuration and replying to init
This is a bit special, in that it allows us to configure the plugin, but then still abort startup by sending `init` with the `disable` flag set.
This commit is contained in:
committed by
Rusty Russell
parent
9826402c99
commit
8717c4e5a2
@@ -34,28 +34,29 @@ async fn main() -> Result<()> {
|
||||
options::Value::Integer(-1),
|
||||
"Which port should the grpc plugin listen for incoming connections?",
|
||||
))
|
||||
.start()
|
||||
.configure()
|
||||
.await?;
|
||||
|
||||
let bind_port = match plugin.option("grpc-port") {
|
||||
Some(options::Value::Integer(-1)) => {
|
||||
log::info!("`grpc-port` option is not configured, exiting.");
|
||||
None
|
||||
plugin.disable("`grpc-port` option is not configured.").await?;
|
||||
return Ok(());
|
||||
}
|
||||
Some(options::Value::Integer(i)) => Some(i),
|
||||
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)),
|
||||
};
|
||||
|
||||
if let Some(bind_port) = bind_port {
|
||||
let bind_addr: SocketAddr = format!("0.0.0.0:{}", bind_port).parse().unwrap();
|
||||
let plugin = plugin.start().await?;
|
||||
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = run_interface(bind_addr, state).await {
|
||||
warn!("Error running the grpc interface: {}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
let bind_addr: SocketAddr = format!("0.0.0.0:{}", bind_port).parse().unwrap();
|
||||
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = run_interface(bind_addr, state).await {
|
||||
warn!("Error running the grpc interface: {}", e);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.join().await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user