diff --git a/scripts/fetch_documentation.sh b/scripts/fetch_documentation.sh --- a/scripts/fetch_documentation.sh +++ b/scripts/fetch_documentation.sh @@ -101,22 +101,37 @@ BITCOIND_PID_FILE="${VERSION_DIR}/bitcoind_${VERSION}.pid" "${INSTALL_DIR}"/bin/bitcoind -regtest -daemon -pid="${BITCOIND_PID_FILE}" + echo "Waiting for bitcoind to spin up..." + READY="no" + for _ in {1..5}; do + if "${INSTALL_DIR}"/bin/bitcoin-cli -regtest help > /dev/null ; then + READY="yes" + break + fi + sleep 1 + done + + if [ "${READY}" != "yes" ]; then + echo "Error: bitcoind is not ready or was not started" + exit 1 + fi + + ninja doc-rpc + + "${INSTALL_DIR}"/bin/bitcoin-cli -regtest stop + PID_WAIT_COUNT=0 - while [ ! -e "${BITCOIND_PID_FILE}" ] + echo "Waiting for bitcoind shut down..." + while [ -e "${BITCOIND_PID_FILE}" ] do ((PID_WAIT_COUNT+=1)) - if [ "${PID_WAIT_COUNT}" -gt 10 ] + if [ "${PID_WAIT_COUNT}" -gt 20 ] then - echo "Timed out waiting for bitcoind PID file" - exit 1 + echo "Timed out waiting for bitcoind to stop" + exit 2 fi sleep 0.5 done - BITCOIND_PID=$(cat "${BITCOIND_PID_FILE}") - - ninja doc-rpc - - kill "${BITCOIND_PID}" # Cache the result cp -R "${BUILD_DIR}/doc/rpc/en/${VERSION}/rpc" "${VERSION_DIR}/"