solana/net/remote/remote-client.sh

107 lines
2.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
2018-09-04 09:21:03 -07:00
cd "$(dirname "$0")"/../..
2018-09-03 21:15:55 -07:00
deployMethod="$1"
entrypointIp="$2"
clientToRun="$3"
if [[ -n $4 ]]; then
export RUST_LOG="$4"
fi
benchTpsExtraArgs="$5"
clientIndex="$6"
2018-09-07 08:46:20 -07:00
missing() {
echo "Error: $1 not specified"
exit 1
}
[[ -n $deployMethod ]] || missing deployMethod
[[ -n $entrypointIp ]] || missing entrypointIp
source net/common.sh
loadConfigFile
2018-09-03 21:15:55 -07:00
threadCount=$(nproc)
if [[ $threadCount -gt 4 ]]; then
threadCount=4
fi
2018-09-03 21:15:55 -07:00
case $deployMethod in
local|tar)
2018-09-03 21:15:55 -07:00
PATH="$HOME"/.cargo/bin:"$PATH"
export USE_INSTALL=1
2019-09-26 13:36:51 -07:00
net/scripts/rsync-retry.sh -vPrc "$entrypointIp:~/.cargo/bin/*" ~/.cargo/bin/
2018-09-03 21:15:55 -07:00
;;
skip)
;;
2018-09-03 21:15:55 -07:00
*)
echo "Unknown deployment method: $deployMethod"
exit 1
esac
case $clientToRun in
solana-bench-tps)
net/scripts/rsync-retry.sh -vPrc \
"$entrypointIp":~/solana/config/bench-tps"$clientIndex".yml ./client-accounts.yml
clientCommand="\
solana-bench-tps \
--entrypoint $entrypointIp:8001 \
2019-12-16 13:05:17 -08:00
--faucet $entrypointIp:9900 \
--duration 7500 \
--sustained \
--threads $threadCount \
$benchTpsExtraArgs \
--read-client-keys ./client-accounts.yml \
"
;;
2019-10-23 09:56:05 -07:00
idle)
2020-01-31 11:14:05 -08:00
# Add the faucet keypair to idle clients for convenience
2019-10-25 16:23:52 -07:00
net/scripts/rsync-retry.sh -vPrc \
"$entrypointIp":~/solana/config/faucet.json ~/solana/
2019-10-23 09:56:05 -07:00
exit 0
;;
*)
echo "Unknown client name: $clientToRun"
exit 1
esac
2018-09-07 20:21:41 -07:00
cat > ~/solana/on-reboot <<EOF
#!/usr/bin/env bash
cd ~/solana
PATH="$HOME"/.cargo/bin:"$PATH"
export USE_INSTALL=1
echo "$(date) | $0 $*" >> client.log
(
sudo SOLANA_METRICS_CONFIG="$SOLANA_METRICS_CONFIG" scripts/oom-monitor.sh
) > oom-monitor.log 2>&1 &
echo \$! > oom-monitor.pid
scripts/fd-monitor.sh > fd-monitor.log 2>&1 &
echo \$! > fd-monitor.pid
scripts/net-stats.sh > net-stats.log 2>&1 &
echo \$! > net-stats.pid
! tmux list-sessions || tmux kill-session
tmux new -s "$clientToRun" -d "
2018-09-07 08:34:42 -07:00
while true; do
2018-09-07 20:50:46 -07:00
echo === Client start: \$(date) | tee -a client.log
2018-09-07 08:34:42 -07:00
$metricsWriteDatapoint 'testnet-deploy client-begin=1'
2018-09-07 20:50:46 -07:00
echo '$ $clientCommand' | tee -a client.log
2018-09-07 08:34:42 -07:00
$clientCommand >> client.log 2>&1
$metricsWriteDatapoint 'testnet-deploy client-complete=1'
done
"
EOF
chmod +x ~/solana/on-reboot
echo "@reboot ~/solana/on-reboot" | crontab -
~/solana/on-reboot
2018-09-07 08:34:42 -07:00
sleep 1
tmux capture-pane -t "$clientToRun" -p -S -100