Changeset View
Changeset View
Standalone View
Standalone View
contrib/teamcity/ibd.sh
Show All 9 Lines | |||||
# Runs a bitcoind process until initial block download is complete. | # Runs a bitcoind process until initial block download is complete. | ||||
# Forwards the exit code from bitcoind onward. | # Forwards the exit code from bitcoind onward. | ||||
### | ### | ||||
MYPID=$$ | MYPID=$$ | ||||
# Setup | # Setup | ||||
: "${TOPLEVEL:=$(git rev-parse --show-toplevel)}" | : "${TOPLEVEL:=$(git rev-parse --show-toplevel)}" | ||||
: "${BUILD_DIR:=${TOPLEVEL}/build}" | |||||
: "${BITCOIND:=${BUILD_DIR}/src/bitcoind}" | |||||
DATA_DIR="${TOPLEVEL}/ibd" | DATA_DIR="${TOPLEVEL}/ibd" | ||||
mkdir -p "${DATA_DIR}" | mkdir -p "${DATA_DIR}" | ||||
DEBUG_LOG="${DATA_DIR}/debug.log" | DEBUG_LOG="${DATA_DIR}/debug.log" | ||||
cleanup() { | cleanup() { | ||||
# Cleanup background processes spawned by this script. | # Cleanup background processes spawned by this script. | ||||
pkill -P ${MYPID} tail || true | pkill -P ${MYPID} tail || true | ||||
} | } | ||||
trap "cleanup" EXIT | trap "cleanup" EXIT | ||||
# Make sure the debug log exists so that tail does not fail | # Make sure the debug log exists so that tail does not fail | ||||
touch "${DEBUG_LOG}" | touch "${DEBUG_LOG}" | ||||
# Show some progress | # Show some progress | ||||
tail -f "${DEBUG_LOG}" | grep 'UpdateTip' | awk 'NR % 10000 == 0' & | tail -f "${DEBUG_LOG}" | grep 'UpdateTip' | awk 'NR % 10000 == 0' & | ||||
callback() { | callback() { | ||||
echo "Initial block download complete." | echo "Initial block download complete." | ||||
# TODO Add more checks to see if IBD completed as expected. | # TODO Add more checks to see if IBD completed as expected. | ||||
# These checks will exit the subshell with a non-zero exit code. | # These checks will exit the subshell with a non-zero exit code. | ||||
} | } | ||||
export -f callback | export -f callback | ||||
LOG_FILE="${DEBUG_LOG}" "${TOPLEVEL}/contrib/devtools/bitcoind-exit-on-log.sh" --grep 'Leaving InitialBlockDownload (latching to false)' --params "-datadir=${DATA_DIR} $*" --callback callback | BITCOIND="${BITCOIND}" \ | ||||
LOG_FILE="${DEBUG_LOG}" \ | |||||
"${TOPLEVEL}/contrib/devtools/bitcoind-exit-on-log.sh" \ | |||||
--grep 'Leaving InitialBlockDownload (latching to false)' \ | |||||
--params "-datadir=${DATA_DIR} $*" \ | |||||
--callback callback |