Browse Source

rework the shutdown of bitcoind

umbrel
kenshin-samourai 5 years ago
parent
commit
166fde54f0
  1. 36
      docker/my-dojo/dojo.sh

36
docker/my-dojo/dojo.sh

@ -55,28 +55,48 @@ start() {
# Stop # Stop
stop() { stop() {
# Shutdown the bitcoin daemon
if [ "$BITCOIND_INSTALL" == "on" ]; then if [ "$BITCOIND_INSTALL" == "on" ]; then
# Renewal of bitcoind onion address
if [ "$BITCOIND_EPHEMERAL_HS" = "on" ]; then if [ "$BITCOIND_EPHEMERAL_HS" = "on" ]; then
docker exec -it tor rm -rf /var/lib/tor/hsv2bitcoind docker exec -it tor rm -rf /var/lib/tor/hsv2bitcoind
fi fi
# Stop the bitcoin daemon
echo "Preparing shutdown of dojo. Please wait."
docker exec -it bitcoind bitcoin-cli \ docker exec -it bitcoind bitcoin-cli \
-rpcconnect=bitcoind \ -rpcconnect=bitcoind \
--rpcport=28256 \ --rpcport=28256 \
--rpcuser="$BITCOIND_RPC_USER" \ --rpcuser="$BITCOIND_RPC_USER" \
--rpcpassword="$BITCOIND_RPC_PASSWORD" \ --rpcpassword="$BITCOIND_RPC_PASSWORD" \
stop stop
# Check if the bitcoin daemon is still up
echo "Preparing shutdown of dojo. Please wait." # wait 3mn max
i="0"
bitcoindDown=$(timeout 3m docker wait bitcoind) while [ $i -lt 18 ]
if [ $bitcoindDown -eq 0 ]; then do
# Check if bitcoind rpc api is responding
timeout 5 docker exec -it bitcoind bitcoin-cli \
-rpcconnect=bitcoind \
--rpcport=28256 \
--rpcuser="$BITCOIND_RPC_USER" \
--rpcpassword="$BITCOIND_RPC_PASSWORD" \
getblockchaininfo > /dev/null
# rpc api is down
if [[ $? > 0 ]]; then
echo "Bitcoin server stopped." echo "Bitcoin server stopped."
else break
fi
# Pause before next try
sleep 5
i=$[$i+1]
done
# Bitcoin daemon is still up
# => force close
if [ $i -eq 18 ]; then
echo "Force shutdown of Bitcoin server." echo "Force shutdown of Bitcoin server."
fi fi
fi fi
# Stop docker containers
yamlFiles=$(select_yaml_files) yamlFiles=$(select_yaml_files)
eval "docker-compose $yamlFiles stop" eval "docker-compose $yamlFiles stop"
} }

Loading…
Cancel
Save