fullnode positional arguments may now be mixed with optional arguments (#4151)

This commit is contained in:
Michael Vines
2019-05-03 20:49:24 -07:00
committed by GitHub
parent 297328ff9a
commit 586fb15c2c
2 changed files with 61 additions and 53 deletions

View File

@ -9,18 +9,13 @@ source "$here"/common.sh
# shellcheck source=scripts/oom-score-adj.sh # shellcheck source=scripts/oom-score-adj.sh
source "$here"/../scripts/oom-score-adj.sh source "$here"/../scripts/oom-score-adj.sh
if [[ -z $CI ]]; then # Skip in CI
# shellcheck source=scripts/tune-system.sh
source "$here"/../scripts/tune-system.sh
fi
fullnode_usage() { fullnode_usage() {
if [[ -n $1 ]]; then if [[ -n $1 ]]; then
echo "$*" echo "$*"
echo echo
fi fi
cat <<EOF cat <<EOF
usage: $0 [--blockstream PATH] [--init-complete-file FILE] [--label LABEL] [--stake LAMPORTS] [--no-voting] [--rpc-port port] [rsync network path to bootstrap leader configuration] [network entry point] usage: $0 [--blockstream PATH] [--init-complete-file FILE] [--label LABEL] [--stake LAMPORTS] [--no-voting] [--rpc-port port] [rsync network path to bootstrap leader configuration] [cluster entry point]
Start a full node Start a full node
@ -162,7 +157,9 @@ stake=43 # number of lamports to assign as stake (plus transaction fee to setup
poll_for_new_genesis_block=0 poll_for_new_genesis_block=0
label= label=
while [[ ${1:0:1} = - ]]; do positional_args=()
while [[ -n $1 ]]; do
if [[ ${1:0:1} = - ]]; then
if [[ $1 = --label ]]; then if [[ $1 = --label ]]; then
label="-$2" label="-$2"
shift 2 shift 2
@ -206,11 +203,15 @@ while [[ ${1:0:1} = - ]]; do
echo "Unknown argument: $1" echo "Unknown argument: $1"
exit 1 exit 1
fi fi
else
positional_args+=("$1")
shift
fi
done done
if $bootstrap_leader; then if $bootstrap_leader; then
if [[ -n $1 ]]; then if [[ ${#positional_args[@]} -ne 0 ]]; then
fullnode_usage "$@" fullnode_usage "Unknown argument: ${positional_args[0]}"
fi fi
[[ -f "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json ]] || [[ -f "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json ]] ||
@ -227,11 +228,12 @@ if $bootstrap_leader; then
default_fullnode_arg --rpc-drone-address 127.0.0.1:9900 default_fullnode_arg --rpc-drone-address 127.0.0.1:9900
default_fullnode_arg --gossip-port 8001 default_fullnode_arg --gossip-port 8001
else else
if [[ -n $3 ]]; then
if [[ ${#positional_args[@]} -gt 2 ]]; then
fullnode_usage "$@" fullnode_usage "$@"
fi fi
read -r leader leader_address shift < <(find_leader "${@:1:2}") read -r leader leader_address shift < <(find_leader "${positional_args[@]}")
shift "$shift" shift "$shift"
fullnode_id_path=$SOLANA_CONFIG_DIR/fullnode-id$label.json fullnode_id_path=$SOLANA_CONFIG_DIR/fullnode-id$label.json
@ -258,6 +260,12 @@ ledger: $ledger_config_dir
accounts: $accounts_config_dir accounts: $accounts_config_dir
====================================================================== ======================================================================
EOF EOF
if [[ -z $CI ]]; then # Skip in CI
# shellcheck source=scripts/tune-system.sh
source "$here"/../scripts/tune-system.sh
fi
default_fullnode_arg --identity "$fullnode_id_path" default_fullnode_arg --identity "$fullnode_id_path"
default_fullnode_arg --voting-keypair "$fullnode_vote_id_path" default_fullnode_arg --voting-keypair "$fullnode_vote_id_path"
default_fullnode_arg --vote-account "$fullnode_vote_id" default_fullnode_arg --vote-account "$fullnode_vote_id"

View File

@ -106,6 +106,7 @@ local|tar)
--stake 0 --stake 0
) )
else else
args+=("$entrypointIp":~/solana "$entrypointIp:8001")
if $leaderRotation; then if $leaderRotation; then
args+=("--stake" "$stake") args+=("--stake" "$stake")
else else
@ -148,7 +149,6 @@ local|tar)
curl --head "$(curl ifconfig.io)" curl --head "$(curl ifconfig.io)"
fi fi
args+=("$entrypointIp":~/solana "$entrypointIp:8001")
./multinode-demo/fullnode.sh "${args[@]}" > fullnode.log 2>&1 & ./multinode-demo/fullnode.sh "${args[@]}" > fullnode.log 2>&1 &
;; ;;
*) *)