solana/net/remote/remote-node.sh

183 lines
4.8 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"
skipSetup="$7"
2018-12-05 17:33:32 -08:00
leaderRotation="$8"
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
[[ -n $skipSetup ]] || missing skipSetup
2018-12-05 17:33:32 -08:00
[[ -n $leaderRotation ]] || missing leaderRotation
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"
2018-12-05 17:33:32 -08:00
leaderRotation=$leaderRotation
2018-09-04 09:21:03 -07:00
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
if [[ $skipSetup = true ]]; then
for configDir in /var/snap/solana/current/config{,-local}; do
if [[ ! -d $configDir ]]; then
echo Error: not a directory: $configDir
exit 1
fi
done
(
set -x
sudo rm -rf /saved-node-config
sudo mkdir /saved-node-config
sudo mv /var/snap/solana/current/config{,-local} /saved-node-config
)
fi
[[ $nodeType = bootstrap-leader ]] ||
net/scripts/rsync-retry.sh -vPrc "$entrypointIp:~/solana/solana.snap" .
if snap list solana; then
sudo snap remove solana
fi
2018-09-03 21:15:55 -07:00
sudo snap install solana.snap --devmode --dangerous
if [[ $skipSetup = true ]]; then
(
set -x
sudo rm -rf /var/snap/solana/current/config{,-local}
sudo mv /saved-node-config/* /var/snap/solana/current/
sudo rm -rf /saved-node-config
)
fi
# 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\" \
skip-setup=$skipSetup \
2018-12-05 17:33:32 -08:00
leader-rotation=\"$leaderRotation\" \
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-leader ]]; 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
# Setup `/var/snap/solana/current` symlink so rsyncing the genesis
# ledger works (reference: `net/scripts/install-rsync.sh`)
sudo rm -rf /var/snap/solana/current
sudo mkdir -p /var/snap/solana
sudo ln -sT /home/solana/solana /var/snap/solana/current
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
2018-12-05 17:33:32 -08:00
maybeNoLeaderRotation=
if ! $leaderRotation; then
maybeNoLeaderRotation="--no-leader-rotation"
fi
2018-09-03 21:15:55 -07:00
case $nodeType in
bootstrap-leader)
if [[ -e /dev/nvidia0 && -x ~/.cargo/bin/solana-fullnode-cuda ]]; then
echo Selecting solana-fullnode-cuda
export SOLANA_CUDA=1
fi
if [[ $skipSetup != true ]]; then
./multinode-demo/setup.sh -t bootstrap-leader $setupArgs
fi
2018-09-03 21:15:55 -07:00
./multinode-demo/drone.sh > drone.log 2>&1 &
2018-12-05 17:33:32 -08:00
./multinode-demo/bootstrap-leader.sh $maybeNoLeaderRotation > 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
if [[ $skipSetup != true ]]; then
./multinode-demo/setup.sh -t fullnode $setupArgs
fi
2018-12-05 17:33:32 -08:00
./multinode-demo/fullnode.sh $maybeNoLeaderRotation "$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