solana/net/remote/remote-node.sh

132 lines
3.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
2018-09-03 21:15:55 -07:00
2018-09-04 09:21:03 -07:00
cd "$(dirname "$0")"/../..
set -x
2018-09-03 21:15:55 -07:00
deployMethod="$1"
nodeType="$2"
publicNetwork="$3"
entrypointIp="$4"
numNodes="$5"
2018-09-04 09:21:03 -07:00
RUST_LOG="$6"
set +x
export RUST_LOG=${RUST_LOG:-solana=warn} # if RUST_LOG is unset, default to warn
2018-09-04 09:21:03 -07:00
2018-09-07 08:46:20 -07:00
missing() {
echo "Error: $1 not specified"
exit 1
}
[[ -n $deployMethod ]] || missing deployMethod
[[ -n $nodeType ]] || missing nodeType
[[ -n $publicNetwork ]] || missing publicNetwork
[[ -n $entrypointIp ]] || missing entrypointIp
[[ -n $numNodes ]] || missing numNodes
2018-09-04 09:21:03 -07:00
cat > deployConfig <<EOF
deployMethod="$deployMethod"
entrypointIp="$entrypointIp"
2018-09-04 09:21:03 -07:00
numNodes="$numNodes"
EOF
2018-09-03 21:15:55 -07:00
source net/common.sh
loadConfigFile
if [[ $publicNetwork = true ]]; then
setupArgs="-p"
else
setupArgs="-l"
fi
2018-09-03 21:15:55 -07:00
case $deployMethod in
snap)
SECONDS=0
[[ $nodeType = bootstrap_fullnode ]] ||
net/scripts/rsync-retry.sh -vPrc "$entrypointIp:~/solana/solana.snap" .
2018-09-03 21:15:55 -07:00
sudo snap install solana.snap --devmode --dangerous
# shellcheck disable=SC2089
2018-09-03 21:15:55 -07:00
commonNodeConfig="\
entrypoint-ip=\"$entrypointIp\" \
metrics-config=\"$SOLANA_METRICS_CONFIG\" \
rust-log=\"$RUST_LOG\" \
setup-args=\"$setupArgs\" \
2018-09-03 21:15:55 -07:00
"
2018-09-04 09:21:03 -07:00
if [[ -e /dev/nvidia0 ]]; then
2018-11-12 19:47:38 -08:00
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
echo "WARNING: GPU detected by snap builds to not support CUDA."
echo " Consider using instances with a GPU to reduce cost."
echo
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
2018-09-04 09:21:03 -07:00
fi
if [[ $nodeType = bootstrap-fullnode ]]; then
nodeConfig="mode=bootstrap-leader+drone $commonNodeConfig"
ln -sf -T /var/snap/solana/current/bootstrap-leader/current fullnode.log
ln -sf -T /var/snap/solana/current/drone/current drone.log
2018-09-03 21:15:55 -07:00
else
nodeConfig="mode=fullnode $commonNodeConfig"
ln -sf -T /var/snap/solana/current/fullnode/current fullnode.log
2018-09-03 21:15:55 -07:00
fi
logmarker="solana deploy $(date)/$RANDOM"
logger "$logmarker"
# shellcheck disable=SC2086,SC2090 # Don't want to double quote "$nodeConfig"
sudo snap set solana $nodeConfig
2018-09-03 21:15:55 -07:00
snap info solana
sudo snap get solana
echo Slight delay to get more syslog output
sleep 2
sudo grep -Pzo "$logmarker(.|\\n)*" /var/log/syslog
echo "Succeeded in ${SECONDS} seconds"
;;
local|tar)
2018-09-03 21:15:55 -07:00
PATH="$HOME"/.cargo/bin:"$PATH"
export USE_INSTALL=1
2018-09-04 09:21:03 -07:00
export RUST_LOG
2018-09-03 21:15:55 -07:00
./fetch-perf-libs.sh
2018-11-12 17:50:16 -08:00
# shellcheck source=/dev/null
source ./target/perf-libs/env.sh
2018-09-04 09:21:03 -07:00
scripts/oom-monitor.sh > oom-monitor.log 2>&1 &
scripts/net-stats.sh > net-stats.log 2>&1 &
2018-09-03 21:15:55 -07:00
case $nodeType in
bootstrap_fullnode)
if [[ -e /dev/nvidia0 && -x ~/.cargo/bin/solana-fullnode-cuda ]]; then
echo Selecting solana-fullnode-cuda
export SOLANA_CUDA=1
fi
./multinode-demo/setup.sh -t bootstrap_leader $setupArgs
2018-09-03 21:15:55 -07:00
./multinode-demo/drone.sh > drone.log 2>&1 &
./multinode-demo/bootstrap-leader.sh > bootstrap-leader.log 2>&1 &
ln -sTf bootstrap-leader.log fullnode.log
2018-09-03 21:15:55 -07:00
;;
fullnode)
net/scripts/rsync-retry.sh -vPrc "$entrypointIp":~/.cargo/bin/ ~/.cargo/bin/
2018-09-03 21:15:55 -07:00
if [[ -e /dev/nvidia0 && -x ~/.cargo/bin/solana-fullnode-cuda ]]; then
echo Selecting solana-fullnode-cuda
export SOLANA_CUDA=1
fi
./multinode-demo/setup.sh -t fullnode $setupArgs
./multinode-demo/fullnode.sh "$entrypointIp":~/solana "$entrypointIp:8001" > fullnode.log 2>&1 &
2018-09-03 21:15:55 -07:00
;;
*)
echo "Error: unknown node type: $nodeType"
exit 1
;;
esac
;;
*)
echo "Unknown deployment method: $deployMethod"
exit 1
esac