Changeset View
Changeset View
Standalone View
Standalone View
contrib/teamcity/ibd.sh
#!/usr/bin/env bash | #!/usr/bin/env bash | ||||
export LC_ALL=C | export LC_ALL=C | ||||
set -euo pipefail | set -euxo pipefail | ||||
### | ### | ||||
# Initial Block Download script. | # Initial Block Download script. | ||||
# | # | ||||
# 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. | ||||
### | ### | ||||
Show All 30 Lines | ( | ||||
# 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. | ||||
) & | ) & | ||||
IBD_PID=$! | IBD_PID=$! | ||||
# When the IBD subshell finishes, kill bitcoind | # When the IBD subshell finishes, kill bitcoind | ||||
( | ( | ||||
# Disable verbosity to avoid bloating the output with sleep prints | |||||
set +x | |||||
while [ -e /proc/${IBD_PID} ]; do sleep 0.1; done | while [ -e /proc/${IBD_PID} ]; do sleep 0.1; done | ||||
set -x | |||||
echo "Cleaning up bitcoin daemon (PID: ${BITCOIND_PID})." | echo "Cleaning up bitcoin daemon (PID: ${BITCOIND_PID})." | ||||
kill ${BITCOIND_PID} | kill ${BITCOIND_PID} | ||||
) & | ) & | ||||
# Wait for bitcoind to exit, whether it exited on its own or IBD finished | # Wait for bitcoind to exit, whether it exited on its own or IBD finished | ||||
wait ${BITCOIND_PID} | wait ${BITCOIND_PID} | ||||
BITCOIND_EXIT_CODE=$? | BITCOIND_EXIT_CODE=$? | ||||
Show All 16 Lines |