Add mechanism to determine when a node has finished booting

This commit is contained in:
Michael Vines
2019-01-22 11:34:12 -08:00
committed by Grimes
parent f630b50902
commit cc88f9bcd6
3 changed files with 59 additions and 31 deletions

View File

@ -21,7 +21,7 @@ usage() {
echo
fi
cat <<EOF
usage: $0 [-x] [--no-leader-rotation] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point]
usage: $0 [-x] [--no-leader-rotation] [--init-complete-file FILE] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point]
Start a full node on the specified network
@ -29,6 +29,7 @@ Start a full node on the specified network
-X [label] - start or restart a dynamically-configured full node with
the specified label
--no-leader-rotation - disable leader rotation
--init-complete-file FILE - create this file, if it doesn't already exist, once node initialization is complete
--rpc-port port - custom RPC port for this node
EOF
@ -39,29 +40,34 @@ if [[ $1 = -h ]]; then
usage
fi
if [[ $1 = -X ]]; then
self_setup=1
self_setup_label=$2
shift 2
elif [[ $1 = -x ]]; then
self_setup=1
self_setup_label=$$
shift
else
self_setup=0
fi
maybe_init_complete_file=
maybe_no_leader_rotation=
if [[ $1 = --no-leader-rotation ]]; then
maybe_no_leader_rotation="--no-leader-rotation"
shift
fi
self_setup=0
maybe_rpc_port=
if [[ $1 = --rpc-port ]]; then
maybe_rpc_port="$1 $2"
shift 2
fi
while [[ ${1:0:1} = - ]]; do
if [[ $1 = -X ]]; then
self_setup=1
self_setup_label=$2
shift 2
elif [[ $1 = -x ]]; then
self_setup=1
self_setup_label=$$
shift
elif [[ $1 = --init-complete-file ]]; then
maybe_init_complete_file="--init-complete-file $2"
shift 2
elif [[ $1 = --no-leader-rotation ]]; then
maybe_no_leader_rotation="--no-leader-rotation"
shift
elif [[ $1 = --rpc-port ]]; then
maybe_rpc_port="$1 $2"
shift 2
else
echo "Unknown argument: $1"
exit 1
fi
done
if [[ -d $SNAP ]]; then
if [[ $(snapctl get leader-rotation) = false ]]; then
@ -230,8 +236,9 @@ if [[ ! -d "$ledger_config_dir" ]]; then
fi
trap 'kill "$pid" && wait "$pid"' INT TERM
# shellcheck disable=SC2086 # Don't want to double quote # maybe_rpc_port
# shellcheck disable=SC2086 # Don't want to double quote maybe_rpc_port or maybe_init_complete_file
$program \
$maybe_init_complete_file \
$maybe_no_leader_rotation \
$maybe_rpc_port \
--identity "$fullnode_json_path" \