#!/bin/bash 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 fi # 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 if [ -z "$PEER" ]; then ./bin/benchmark -ip $ip -port $port -config_file $config -log_folder $log_folder $DB -min_peers $MIN & else ./bin/benchmark -ip $ip -port $port -log_folder $log_folder $DB $PEER -min_peers $MIN & sleep 1 fi fi done < $config # Emulate node offline (sleep 45; killnode $KILLPORT) & echo "launching txgen ..."Z if [ "$TXGEN" == "true" ]; then echo "launching txgen ..." if [ -z "$PEER" ]; then ./bin/txgen -config_file $config -log_folder $log_folder -duration $DURATION else ./bin/txgen -log_folder $log_folder -duration $DURATION $PEER fi fi cleanup