vulpemventures / nigiri

🍣 A delicious docker box for special Bitcoin, Lightning and Liquid cookings
https://nigiri.vulpem.com
MIT License
271 stars 44 forks source link

How to handle waiting for "ready" after start? #148

Open futurepaul opened 2 years ago

futurepaul commented 2 years ago

Was trying to use nigiri in a script and the lightning faucet was failing. Turns out the problem is I was calling nigiri faucet cln 1 too quickly after start, and something wasn't actually ready yet to accomplish that.

Not sure best solution to this. Possibly an endpoint to poll for "ready" before continuing the script? Or perhaps best move is I just poll the relevant components myself and continue once I know they're ready.

tiero commented 2 years ago

we do something like the bash script below or just an quick & dirty sleep 3 should work :)

function waitForNode () {
  while true; do
    if $1 getblockchaininfo 2>&1 | grep blocks > /dev/null 2>&1; then
      break 
    fi
    sleep 1
  done  
}
tiero commented 2 years ago

But we can offer a HTTP endpoint like /ready https://github.com/vulpemventures/nigiri-chopsticks that does this for you if you prefer

futurepaul commented 2 years ago

we'll try out your bash script technique and I'll let you know if it doesn't work, thank you!