#!/bin/bash ROOT=$(dirname $0)/.. set -eo pipefail function cleanup() { for pid in `/bin/ps -fu $USER| grep "benchmark\|txgen\|soldier\|commander\|profiler\|beacon" | grep -v "grep" | grep -v "vi" | awk '{print $2}'`; do echo 'Killed process: '$pid kill -9 $pid 2> /dev/null done } function killnode() { local port=$1 if [ -n "port" ]; then pid=$(/bin/ps -fu $USER | grep "benchmark" | grep "$port" | awk '{print $2}') echo "killing node with port: $port" kill -9 $pid 2> /dev/null echo "node with port: $port is killed" fi } trap cleanup SIGINT SIGTERM function usage { local ME=$(basename $0) cat< $log_folder/beacon.log 2>&1 & sleep 1 #wait or beachchain up # Start nodes while IFS='' read -r line || [[ -n "$line" ]]; do IFS=' ' read ip port mode shardID <<< $line #echo $ip $port $mode if [ "$mode" != "client" ]; then $ROOT/bin/benchmark -ip $ip -port $port -log_folder $log_folder $DB -min_peers $MIN & sleep 0.5 fi done < $config # Emulate node offline (sleep 45; killnode $KILLPORT) & echo "launching txgen ..."Z if [ "$TXGEN" == "true" ]; then echo "launching txgen ..." $ROOT/bin/txgen -log_folder $log_folder -duration $DURATION fi cleanup