github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/demo/_params.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  declare -ri N="${N:-3}"
     4  declare -ri M="${M:-2}"
     5  declare -r  TAG="${TAG:-latest}"
     6  
     7  PORT_BASE=3000
     8  RPCP_BASE=4000
     9  WSP_BASE=4500
    10  PPROFP_BASE=6060
    11  PROMETHEUSP_BASE=19090
    12  
    13  attach_and_exec() {
    14      local i=$1
    15      local CMD=$2
    16      local RPCP=$(($RPCP_BASE+$i))
    17  
    18      for attempt in $(seq 40)
    19      do
    20          if (( attempt > 5 ))
    21          then
    22              echo "  - attempt ${attempt}: " >&2
    23          fi
    24  
    25          res=$(../build/demo_u2u --exec "${CMD}" attach http://127.0.0.1:${RPCP} 2> /dev/null)
    26          if [ $? -eq 0 ]
    27          then
    28              #echo "success" >&2
    29              echo $res
    30              return 0
    31          else
    32              #echo "wait" >&2
    33              sleep 1
    34          fi
    35      done
    36      echo "failed RPC connection to ${NAME}" >&2
    37      return 1
    38  }