2018-12-07 10:00:35 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Start the bootstrap leader node
|
|
|
|
#
|
|
|
|
|
|
|
|
here=$(dirname "$0")
|
|
|
|
# shellcheck source=multinode-demo/common.sh
|
|
|
|
source "$here"/common.sh
|
|
|
|
|
|
|
|
# shellcheck source=scripts/oom-score-adj.sh
|
|
|
|
source "$here"/../scripts/oom-score-adj.sh
|
|
|
|
|
|
|
|
if [[ -d "$SNAP" ]]; then
|
|
|
|
# Exit if mode is not yet configured
|
|
|
|
# (typically the case after the Snap is first installed)
|
|
|
|
[[ -n "$(snapctl get mode)" ]] || exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
[[ -f "$SOLANA_CONFIG_DIR"/bootstrap-leader.json ]] || {
|
|
|
|
echo "$SOLANA_CONFIG_DIR/bootstrap-leader.json not found, create it by running:"
|
|
|
|
echo
|
|
|
|
echo " ${here}/setup.sh"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ -n "$SOLANA_CUDA" ]]; then
|
|
|
|
program="$solana_fullnode_cuda"
|
|
|
|
else
|
|
|
|
program="$solana_fullnode"
|
|
|
|
fi
|
|
|
|
|
2019-02-21 16:16:09 -07:00
|
|
|
maybe_blockstream=
|
2019-01-22 11:34:12 -08:00
|
|
|
maybe_init_complete_file=
|
2018-12-05 17:33:32 -08:00
|
|
|
maybe_no_leader_rotation=
|
|
|
|
|
2019-01-22 11:34:12 -08:00
|
|
|
while [[ -n $1 ]]; do
|
|
|
|
if [[ $1 = --init-complete-file ]]; then
|
|
|
|
maybe_init_complete_file="--init-complete-file $2"
|
|
|
|
shift 2
|
2019-02-21 16:16:09 -07:00
|
|
|
elif [[ $1 = --blockstream ]]; then
|
|
|
|
maybe_blockstream="$1 $2"
|
2019-02-15 22:52:27 -08:00
|
|
|
shift 2
|
2019-01-22 11:34:12 -08:00
|
|
|
elif [[ $1 = --no-leader-rotation ]]; then
|
|
|
|
maybe_no_leader_rotation="--no-leader-rotation"
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
echo "Unknown argument: $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-12-05 17:33:32 -08:00
|
|
|
|
|
|
|
if [[ -d $SNAP ]]; then
|
|
|
|
if [[ $(snapctl get leader-rotation) = false ]]; then
|
|
|
|
maybe_no_leader_rotation="--no-leader-rotation"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-12-15 08:42:56 -08:00
|
|
|
tune_system
|
2018-12-07 10:00:35 -08:00
|
|
|
|
|
|
|
trap 'kill "$pid" && wait "$pid"' INT TERM
|
2019-01-18 10:26:07 -08:00
|
|
|
$solana_ledger_tool --ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger verify
|
2019-01-22 11:34:12 -08:00
|
|
|
|
2019-02-21 16:16:09 -07:00
|
|
|
# shellcheck disable=SC2086 # Don't want to double quote maybe_blockstream or maybe_init_complete_file
|
2018-12-07 10:00:35 -08:00
|
|
|
$program \
|
2019-02-21 16:16:09 -07:00
|
|
|
$maybe_blockstream \
|
2019-01-22 11:34:12 -08:00
|
|
|
$maybe_init_complete_file \
|
2018-12-05 17:33:32 -08:00
|
|
|
$maybe_no_leader_rotation \
|
2018-12-07 10:00:35 -08:00
|
|
|
--identity "$SOLANA_CONFIG_DIR"/bootstrap-leader.json \
|
|
|
|
--ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger \
|
2019-01-17 08:09:52 -08:00
|
|
|
--rpc-port 8899 \
|
2018-12-07 10:00:35 -08:00
|
|
|
> >($bootstrap_leader_logger) 2>&1 &
|
|
|
|
pid=$!
|
|
|
|
oom_score_adj "$pid" 1000
|
|
|
|
wait "$pid"
|